So for example purposes, I have the following table:
| | A | B |
| |------------|----------|
| 1 |Description |Amount |
| 2 |------------|----------|
| 3 |Item1 | 5.00|
| 4 |Item2** | 29.00|
| 5 |Item3 | 1.00|
| 6 |Item4** | 5.00|
| 7 |------------|----------|
| 8 |Star Total | 34.00|
| 9 |------------|----------|
I want to create a formula in B8 that calculates the sum of the amounts if the description of that amount contains "**" (or some other denoting text). In this particular example I would like a formula that returns 34 since only Item2 and Item4 contain "**".
I tried to use something like this, but it only worked based on the value in A3:
=SUMIF(A3:A6, ISNUMBER(SEARCH("**", A3)), B3:B6)
Any suggestions would be appreciated!
Sum if cell contains text If you are looking for an Excel formula to find cells containing specific text and sum the corresponding values in another column, use the SUMIF function. Where A2:A10 are the text values to check and B2:B10 are the numbers to sum. To sum with multiple criteria, use the SUMIFS function.
The SUMIF function is conditional if the function used to sum the cells based on certain criteria, not the criteria can be a certain text too. For example, we want to sum up a group of cells. If the adjacent cell has a specified text, we can use the function: =SUMIF(Text Range,” Text,” cells range for sum).
If you want, you can apply the criteria to one range and sum the corresponding values in a different range. For example, the formula =SUMIF(B2:B5, "John", C2:C5) sums only the values in the range C2:C5, where the corresponding cells in the range B2:B5 equal "John."
You can provide cell references as arguments of the SUMIFS function.
The asterisk is the wildcard symbol that can be used in Sumif(), so you may want to change the denoting text to some other symbols, for example @@. Then this formula will work:
=SUMIF(A2:A10,"*@@*",B2:B10)
If you want to keep the asterisks, the formula gets a bit curlier.
=SUMIF(A2:A10,"*~*~**",B2:B10)
The two middle asterisks are escaped with the tilde character.
You can escape the wildcard character and turn it into a literal *
by prefixing it with a swung dash (tilde, ~
) and so leave your data unchanged:
=SUMIF(A2:A7,"*~*~*",B2:B7)
IMO worthwhile because astrisks are relatively 'elegant'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With