How to count cells that contain part of a text?

Rhadida

Board Regular
Joined
Nov 26, 2003
Messages
159
I'd like to know if there is a formula or VBA code, that can count cells in a single column, that contain part of a text. Like you can do with an autofilter (contains..).

For example:

Say cell A3 contains the text "The customer is living in England" and so on.
How can I count the number of cells that contain England or Holland or living?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi

This is one way:

=SUM(COUNTIF(A:A,{"*England*","*Holland*"}))

Note that the above will count a cell containing both England and Holland twice - is this likely to be a problem?
 
Upvote 0
Thanks for the very quick reply, didn't know about the {} in the formula's. This will centainly help me out in other spreadsheets! :D
 
Upvote 0
or try these:
Excel Workbook
ABCDEFG
1List of text
2The customer lives in LondonWord of interestLondon3CTRL Shift Enter
3London is a great city to live in3CTRL Shift Enter
4Only London has double decker bus3Just Enter
Sheet2
 
Upvote 0
or try these:
Excel Workbook
ABCDEFG
1List of text******
2The customer lives in London*Word of interestLondon3CTRL Shift Enter*
3London is a great city to live in***3CTRL Shift Enter*
4Only London has double decker bus***3Just Enter*
Sheet2


Thanks for the reply, this will be usefull as well ;-)
 
Upvote 0
Btw do you also know, how I can exclude certain texts from the search?

Like counting all cells without the word "London" or "Holland"?
 
Upvote 0
Hi

This is one way:

=SUM(COUNTIF(A:A,{"*England*","*Holland*"}))

Note that the above will count a cell containing both England and Holland twice - is this likely to be a problem?

This won't be a problem, since the name can only occur once.

btw is it also possible to count the amount cells, that meets 2 requirements in 2 different colomns? For example:

1 column contains the values: Man, Woman, Child and the other column contains the values likes b4, like "living in England'" or "Holland is his birthplace".
I'd like to count the amount of "Man" that also have "England" in the other column?
 
Upvote 0
...is it also possible to count the amount cells, that meets 2 requirements in 2 different colomns? For example:

1 column contains the values: Man, Woman, Child and the other column contains the values likes b4, like "living in England'" or "Holland is his birthplace".
I'd like to count the amount of "Man" that also have "England" in the other column?
Adjust the ranges and try:
=SUMPRODUCT(-(A1:A1000="Man"),-ISNUMBER(SEARCH("England",B1:B1000)))
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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