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:

[TABLE="width: 500"]
<tbody>[TR]
[TD="align: center"]Set 1[/TD]
[TD="align: center"]Set 2[/TD]
[TD="align: center"]Count[/TD]
[/TR]
[TR]
[TD]Good fruit[/TD]
[TD]This apple is red[/TD]
[TD="align: center"]5[/TD]
[/TR]
[TR]
[TD]Bad fruit[/TD]
[TD]This apple is green[/TD]
[TD="align: center"]6[/TD]
[/TR]
[TR]
[TD]Bad dessert[/TD]
[TD]This cake is red[/TD]
[TD="align: center"]8[/TD]
[/TR]
[TR]
[TD]Good meat[/TD]
[TD]This beef is red[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]Bad fruit[/TD]
[TD]This apple is red[/TD]
[TD="align: center"]1[/TD]
[/TR]
</tbody>[/TABLE]

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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,223,264
Messages
6,171,081
Members
452,377
Latest member
bradfordsam

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