简体   繁体   English

Excel Advance Sumif公式

[英]Excel Advance Sumif formula

I have a formula to look through a list and if it contains a specific string add the cells beside it. 我有一个公式来查看列表,如果它包含特定的字符串,请在其旁边添加单元格。

Cell D5 = "String1" 'for example
=SUMIF($A$4:$A$250,"*- "&D5&"*",$C$4:$C$250)

The problem I face is when I search for the " -String1 " there are times where there are multiple strings I'm searching for - example: 我遇到的问题是,当我搜索“ -String1 ”时,有时我正在搜索多个字符串-例如:

在此处输入图片说明

with the above formula it would add 300 for each string1, string2, and string4 cells and adds 400 for both string1 and string3 使用上面的公式,它将为每个string1,string2和string4单元格添加300,并为string1和string3都添加400

The formula I am looking for is to search for " -string? " and divide by cell next to it the number of "*- *" there are in the line 我正在寻找的公式是搜索“ -string? ”并按其旁边的单元格除以“ *-*”

Use this array formula: 使用此数组公式:

=SUM(IF(ISNUMBER(SEARCH(D5,$A$4:$A$24)),$C$4:$C$24/(LEN($A$4:$A$24)-LEN(SUBSTITUTE($A$4:$A$24,"- ","x")))))

Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting Edit mode. 作为数组公式,退出编辑模式时,需要使用Ctrl-Shift-Enter而不是Enter进行确认。 If done correctly then Excel will put {} around the formula. 如果操作正确,则Excel会将{}放在公式周围。

![在此处输入图片描述

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

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