Sum Cells In a Range IF 3 'Contains' Criteria are Met

darstar

New Member
Joined
Oct 19, 2018
Messages
3
Hi all, hoping you can help me. I want to sum cells within a range, only if 3 criteria are met, but each criteria is specific to finding specific text within other cells in the same row. For example:

Set 1Set 2Count
Good fruitThis apple is red5
Bad fruitThis apple is green6
Bad dessertThis cake is red8
Good meatThis beef is red3
Bad fruitThis apple is red1

<tbody>
</tbody>

I would like to create a formula that sums the numbers in column 'Count' if the following criteria are met for column 'Set 1' and 'Set 2':

'Set 1' - Cell contains the word "fruit"
'Set 2' - Cell contains the word "apple" AND "red"

In this example, the formula should return "6."

Apologies, I know the example looks a bit weird.

Would really appreciate your help! Thanks in advance.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Welcome to the forum.

You can use SUMIFS for that:

=SUMIFS(C:C,A:A,"*fruit*",B:B,"*apple*",B:B,"*red*")
 
Upvote 0
Welcome to the forum.

You can use SUMIFS for that:

=SUMIFS(C:C,A:A,"*fruit*",B:B,"*apple*",B:B,"*red*")

---------

Thank you for both the welcome, as well as the reply, Rory!

If I may ask another question, what does the use of the "*" do in this context? Sorry, I've never seen asterisks used in a formula before.
 
Upvote 0
It's a wildcard meaning any number of characters (including none). So "*apple*" looks for apple anywhere in the text, whereas "apple*" would look for text starting with apple, and "*apple" would look for text ending with apple. (all 3 would match just apple). You can also use a ? as a wildcard to indicate 1 character.
 
Last edited:
Upvote 0
Wonderful, thank you! One follow-up question, is there any way to use a cell value to represent the text within the "**"?

For example, rather than typing "*apple*", if the word "apple" is in cell A2, I would, ideally, like to use the cell value in place of the text in the formula (i.e. "*A2*").

This does not seem to work, which is why I'm here :) Any potential workarounds?
 
Upvote 0
You can use:

"*"&A2&"*"

as the criterion.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top