Count cells that contain both of these two words

champchamp

New Member
Joined
Jan 22, 2020
Messages
6
Office Version
  1. 2016
I have a column like this

Red Ferrari Blue Red Ferrari
Blue Ferrari Yellow
Yellow Ferrarired
Red Lambo Red

I want to scan through the whole column and count the cells that contain BOTH words "ferrari" and "red" regardless of where they are.
So in this case the count should be 2 (first and third rows are the only ones containing both words regardless of how many times these words occur).

What i tried so far was :
=SUM(COUNTIF(A:A,{"red","ferrari"}))

However this gives a sum of all occurances and not the number of cells.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Thanks. I found a better solution:

=COUNTIFS(A:A,"*red*",A:A,"*ferrari*")

My problem now is that I want to replace red with a cell number. If I just replace red with B1 it doesn't work with the *.

So I need this but it doesn't work:
=COUNTIFS(A:A,"*B1*",A:A,"*B2*")



if I use this it doesn't work the way I want it:
=COUNTIFS(A:A,B1,A:A,B2)

Any ideas?
 
Upvote 0
Excel Formula:
=COUNTIFS(A:A,"*"&B1&"*",A:A,"*"&B2&"*")

But just as a word of warning, it would count text such as "credit nefferrarian"
That is, it does not count words as per your description..
count the cells that contain BOTH words "ferrari" and "red"
 
Last edited:
Upvote 0
Solution
ignore - Peter_SSs - replied as i posted
 
Upvote 0
Excel Formula:
=COUNTIFS(A:A,"*"&B1&"*",A:A,"*"&B2&"*")

But just as a word of warning, it would count text such as "credit nefferrarian"
That is, it does not count words as per your description..

This is perfect. Thanks so much.
Thanks for the warning. I will keep that in mind.

You guys are awesome.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,215,026
Messages
6,122,738
Members
449,094
Latest member
dsharae57

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