ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CountIf query for words within string (https://www.excelbanter.com/excel-programming/418743-countif-query-words-within-string.html)

JohnH

CountIf query for words within string
 
Hi all,

I am trying to find a formula that will count specific words within a range.
Some of the cells may be part of a text string for example:

count the word "red" within cells containing "red", "red 1", "red 2" etc.
I know this can be done with the formula...=countif(range, "*red*")

The real question is if I can do this by searching for a word within a cell
value? So, if cell "A1" equals "red", count "red", if cell "A1" equals
"blue", count blue.
Thanks in advance.


Peter T

CountIf query for words within string
 
If I follow simply amend your formula

=countif(range, "*" & A1 & "*")

Regards,
Peter T

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

I am trying to find a formula that will count specific words within a
range.
Some of the cells may be part of a text string for example:

count the word "red" within cells containing "red", "red 1", "red 2" etc.
I know this can be done with the formula...=countif(range, "*red*")

The real question is if I can do this by searching for a word within a
cell
value? So, if cell "A1" equals "red", count "red", if cell "A1" equals
"blue", count blue.
Thanks in advance.





All times are GMT +1. The time now is 03:21 PM.

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