ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count If query within string (https://www.excelbanter.com/excel-programming/418745-count-if-query-within-string.html)

JohnH

Count If query within string
 
Hi all,

I am trying to count a word within a range of cells. Some cells may contain
the word within a text string for example:
Count the word "red" within "red 1", "red 2", "red 3" etc.
I know this can be done with the formula..."=CountIf(range, "*red*")"

The real question is if this is possible to search by a cell value?
ie. If cell "A1" equals "red" then count "red", if "A1" equals "blue" then
count the number of times "blue" appears.

Hope this makes sense. Thank you.

Bob Phillips[_3_]

Count If query within string
 
=COUNTIF(range,"*"&A1&"*")

--
__________________________________
HTH

Bob

"JohnH" wrote in message
...
Hi all,

I am trying to count a word within a range of cells. Some cells may
contain
the word within a text string for example:
Count the word "red" within "red 1", "red 2", "red 3" etc.
I know this can be done with the formula..."=CountIf(range, "*red*")"

The real question is if this is possible to search by a cell value?
ie. If cell "A1" equals "red" then count "red", if "A1" equals "blue" then
count the number of times "blue" appears.

Hope this makes sense. Thank you.





All times are GMT +1. The time now is 01:22 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com