ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using a sub string in a COUNTIF (https://www.excelbanter.com/excel-discussion-misc-queries/237245-using-sub-string-countif.html)

PeteJ

Using a sub string in a COUNTIF
 
I currently use a COUNTIF to count how many times a name occurs in a range of
cells. That works fine if the cell contains only that string. But how can I
do the COUNTIF if the cell has other text in it as well? For instance, I'm
counting for "Nancy" in the cells, but if the cell contains "Bob and Nancy",
I want to count it as well. I assume I need to use the "SEARCH" or "FIND"
function, but can't figure out what argument to feed it:

=COUNTIF(A1:D15, FIND("Nancy, ?))

Other ideas?

Thanks,

Pete

Jacob Skaria

Using a sub string in a COUNTIF
 
=COUNTIF(A1:D15,"*Nancy*")

If this post helps click Yes
---------------
Jacob Skaria


"PeteJ" wrote:

I currently use a COUNTIF to count how many times a name occurs in a range of
cells. That works fine if the cell contains only that string. But how can I
do the COUNTIF if the cell has other text in it as well? For instance, I'm
counting for "Nancy" in the cells, but if the cell contains "Bob and Nancy",
I want to count it as well. I assume I need to use the "SEARCH" or "FIND"
function, but can't figure out what argument to feed it:

=COUNTIF(A1:D15, FIND("Nancy, ?))

Other ideas?

Thanks,

Pete


[email protected]

Using a sub string in a COUNTIF
 

This was helpful tip. Using wildcards!!
Thanks Jacob!

Cheers
Nitin

On Saturday, 18 July 2009 03:58:01 UTC+10, Jacob Skaria wrote:
=COUNTIF(A1:D15,"*Nancy*")

If this post helps click Yes
---------------
Jacob Skaria


"PeteJ" wrote:

I currently use a COUNTIF to count how many times a name occurs in a range of
cells. That works fine if the cell contains only that string. But how can I
do the COUNTIF if the cell has other text in it as well? For instance, I'm
counting for "Nancy" in the cells, but if the cell contains "Bob and Nancy",
I want to count it as well. I assume I need to use the "SEARCH" or "FIND"
function, but can't figure out what argument to feed it:

=COUNTIF(A1:D15, FIND("Nancy, ?))

Other ideas?

Thanks,

Pete




All times are GMT +1. The time now is 11:54 PM.

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