#1   Report Post  
Thermometer
 
Posts: n/a
Default COUNTIF woes

I'm trying to do something simple, or at least I thougth I was.
If I have the word BLAH in cell C20 and then in cell D20 I have the
formula =COUNTIF(C20,LEFT(C20,2)="BL")
why is the result 0 (zero) instead of 1 ?
Thanks for any advice.

  #2   Report Post  
Gary Brown
 
Posts: n/a
Default

BL does not equal BLAH, therefore no cells found, therefore found = 0.
Try...
=If(Left(C20,2)="BL",1,0)

HTH,
Gary Brown


"Thermometer" wrote:

I'm trying to do something simple, or at least I thougth I was.
If I have the word BLAH in cell C20 and then in cell D20 I have the
formula =COUNTIF(C20,LEFT(C20,2)="BL")
why is the result 0 (zero) instead of 1 ?
Thanks for any advice.


  #3   Report Post  
Thermometer
 
Posts: n/a
Default

But then how would I expand that to count all the occurrances of BL in
a column, such as c20:c:500 ?? Sorry, I should have explaned my
problem further. One cell was not a good example. Tha's where the
COUNTIF comes in, I think.

  #4   Report Post  
Alan Beban
 
Posts: n/a
Default

Thermometer wrote:
But then how would I expand that to count all the occurrances of BL in
a column, such as c20:c:500 ?? Sorry, I should have explaned my
problem further. One cell was not a good example. Tha's where the
COUNTIF comes in, I think.

=COUNTIF(C20:C500,*BL*) or, if C20 contains BLAH

=COUNTIF(C20:C500,"*"&LEFT(C20,2)&"*")

Alan Beban
  #5   Report Post  
Dave Peterson
 
Posts: n/a
Default

Just a small typo on the first formula:
=COUNTIF(C20:C500,"*BL*")

(added a pair of double quotes)

Alan Beban wrote:

Thermometer wrote:
But then how would I expand that to count all the occurrances of BL in
a column, such as c20:c:500 ?? Sorry, I should have explaned my
problem further. One cell was not a good example. Tha's where the
COUNTIF comes in, I think.

=COUNTIF(C20:C500,*BL*) or, if C20 contains BLAH

=COUNTIF(C20:C500,"*"&LEFT(C20,2)&"*")

Alan Beban


--

Dave Peterson


  #6   Report Post  
Thermometer
 
Posts: n/a
Default

Thanks all for the advice. I appreciate the help.
Therm

  #7   Report Post  
JulieD
 
Posts: n/a
Default

Hi

because the formula evaluates in this order
=COUNTIF(C20,"BL"="BL")
=COUNTIF(C20,TRUE)
=COUNTIF("BLAH",TRUE)
which = 0

if you're doing more than one cell in the range to check the following
should give you what you want
=SUMPRODUCT(--(LEFT(C20:C30,2)="BL"))

Cheers
JulieD

"Thermometer" wrote in message
oups.com...
I'm trying to do something simple, or at least I thougth I was.
If I have the word BLAH in cell C20 and then in cell D20 I have the
formula =COUNTIF(C20,LEFT(C20,2)="BL")
why is the result 0 (zero) instead of 1 ?
Thanks for any advice.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIF in one colum then COUNTIF in another...??? JonnieP Excel Worksheet Functions 3 February 22nd 05 02:55 PM
want to count in two columns; countif (colA=x AND colB=y)? Heather Murch Excel Worksheet Functions 1 February 17th 05 03:47 PM
COUNTIF text where there is more than one word in a cell Abi Excel Worksheet Functions 2 January 20th 05 03:32 AM
Countif - Countif maswinney Excel Worksheet Functions 3 November 15th 04 11:06 PM
countif, again Liz G Excel Worksheet Functions 2 November 1st 04 11:20 PM


All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"