我正在寻找SUMPRODUCT公式,或类似的公式,它做同样的事情。它应该执行以下操作:
编辑:添加第3点。
我会添加一张图片来形象化我的意思。希望有人可以帮助我!
答案 0 :(得分:3)
使用一些辅助列,您可以使用类似的东西(在新标签中打开以获得更大版本):
公式:
在B2中删除空格,从而获得“干净”的ZIP并检查长度:
=IF(LEN(SUBSTITUTE(A2," ",""))=6,SUBSTITUTE(A2," ",""),"")
在C2中,得到总和:
=IFERROR(IF(AND(ISNUMBER(LEFT(B2,4)*1),CODE(MID(LOWER(B2),5,1))>=97,CODE(MID(LOWER(B2),5,1))<=122,CODE(RIGHT(LOWER(B2)))>=97,CODE(RIGHT(LOWER(B2)))<=122),SUMPRODUCT($H$2:$K$8*($G$2:$G$8=B2)),""),"")
在G2中,我使用与B2中相同的一个:
=IF(LEN(SUBSTITUTE(F2," ",""))=6,SUBSTITUTE(F2," ",""),"")
如果没有助手,由于重复部分,公式会变得更长:
=IFERROR(IF(AND(LEN(SUBSTITUTE(A2," ",""))=6,ISNUMBER(LEFT(SUBSTITUTE(A2," ",""),4)*1),CODE(MID(LOWER(SUBSTITUTE(A2," ","")),5,1))>=97,CODE(MID(LOWER(SUBSTITUTE(A2," ","")),5,1))<=122,CODE(RIGHT(LOWER(SUBSTITUTE(A2," ",""))))>=97,CODE(RIGHT(LOWER(SUBSTITUTE(A2," ",""))))<=122),SUMPRODUCT($H$2:$K$8*(SUBSTITUTE($F$2:$F$8," ","")=SUBSTITUTE(A2," ",""))),""),"")
或者
=IFERROR(
IF(
AND(
LEN(SUBSTITUTE(A2," ",""))=6, ' Check length
ISNUMBER(LEFT(SUBSTITUTE(A2," ",""),4)*1), ' Check numbers
CODE(MID(LOWER(SUBSTITUTE(A2," ","")),5,1))>=97, ' Check if letter
CODE(MID(LOWER(SUBSTITUTE(A2," ","")),5,1))<=122, ' Check if letter
CODE(RIGHT(LOWER(SUBSTITUTE(A2," ",""))))>=97, ' Check if letter
CODE(RIGHT(LOWER(SUBSTITUTE(A2," ",""))))<=122 ' Check if letter
),
SUMPRODUCT(
$H$2:$K$8*
(SUBSTITUTE($F$2:$F$8," ","")=SUBSTITUTE(A2," ",""))),
""
),
""
)
哎呀,忘记了IFERROR
不在2003年。我使用它的唯一原因是MID
会返回一个空字符串,CODE
随后会出错。您可以使用下面的代码来确保字符串首先是6个字符:
=IF(LEN(SUBSTITUTE(A2," ",""))=6,IF(AND(ISNUMBER(LEFT(SUBSTITUTE(A2," ",""),4)*1),CODE(MID(LOWER(SUBSTITUTE(A2," ","")),5,1))>=97,CODE(MID(LOWER(SUBSTITUTE(A2," ","")),5,1))<=122,CODE(RIGHT(LOWER(SUBSTITUTE(A2," ",""))))>=97,CODE(RIGHT(LOWER(SUBSTITUTE(A2," ",""))))<=122),SUMPRODUCT($H$2:$K$8*(SUBSTITUTE($F$2:$F$8," ","")=SUBSTITUTE(A2," ",""))),""),"")
答案 1 :(得分:1)
这里有一个验证荷兰邮政编码的公式
=AND(LEN(A2)=6; ISNUMBER(VALUE(LEFT(A2;4))); CODE(MID(LOWER(A2);5;1)) >= 97; CODE(MID(LOWER(A2);5;1)) <= 122; CODE(MID(LOWER(A2);6;1)) >= 97; CODE(MID(LOWER(A2);6;1)) <= 122)
0-9 = ASCII码48到57
a-z = ASCII代码97到122(小写)
如果您有荷兰语版本的Excel,则公式为:
=EN(LENGTE(A2)=6; ISGETAL(WAARDE(LINKS(A2;4))); CODE(DEEL(KLEINE.LETTERS(A2);5;1)) >= 97; CODE(DEEL(KLEINE.LETTERS(A2);5;1)) <= 122; CODE(DEEL(KLEINE.LETTERS(A2);6;1)) >= 97; CODE(DEEL(KLEINE.LETTERS(A2);6;1)) <= 122)