简体   繁体   English

Excel:带有通配符的 SUMPRODUCT 与确切的单元格内容不匹配

[英]Excel: SUMPRODUCT with wildcard not matching exact cell content

I would like to make use of SUMPRODUCT depending of an specific identifier (eg 01, 02_01 and so on).我想根据特定标识符(例如 01、02_01 等)使用 SUMPRODUCT。 My solution looks like this so far:到目前为止,我的解决方案如下所示:

=SUMPRODUCT(--(ISNUMBER(SEARCH("??",E2:E9)))*F2:F9*G2:G9)

Excel中的最小示例

Now, actually I expected a sum of 1332 matching only line 2 and 7 but it matches all lines.现在,实际上我预计总和 1332 仅匹配第 2 行和第 7 行,但它匹配所有行。 How do I overcome this unwanted behavior?如何克服这种不受欢迎的行为? A VBA solution would be fine too. VBA 解决方案也可以。

Thanks in advance!提前致谢!

You can add something to the front and end to ensure it is looking at the whole and not part:您可以在前端和后端添加一些内容,以确保它看到的是整体而不是部分:

=SUMPRODUCT(--(ISNUMBER(SEARCH("|"&"??"&"|","|"&E2:E9&"|")))*F2:F9*G2:G9)

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM