Countif equals and not equals not working correctly

sunrise06

Active Member
Joined
Oct 27, 2006
Messages
264
Office Version
  1. 365
Platform
  1. Windows
I have a column of text values that appear to be numeric and need to remain as text values. When I use this formula =COUNTIF($BH$5:$BH$16,"00") I get the correct result, but if I use the following formula I do no, =COUNTIF($BH$5:$BH$18"<>00").

However, if the values are changed to alpha characters, it works fine - e.g., =COUNTIF($BG$5:$BG$16,"F") or =COUNTIF($BG$5:$BG$16,"<>F")

Any ideas why that is?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
That does not seem to work. For the "<>??" I get 0 and the result should be 2.
 
Upvote 0
It worked for me. Maybe something about your data I may not appreciate. As I understand your description, the data is text-numbers.

Alternatively, If the equals criteria formula works and you have a fixed range you can calculate the <> criteria...

=ROWS($BH$5:$BH$16) - COUNTIF($BH$5:$BH$16,"=??")
 
Upvote 0
Hi,

I can confirm what OP is describing, thou I don't know why Excel is treating the Text 00 differently when tested within the COUNTIF:


Book1
ABCDEF
10047TRUEFALSE3
210FALSETRUE
300TRUEFALSE
420FALSETRUE
511FALSETRUE
600TRUEFALSE
700TRUEFALSE
Sheet338
Cell Formulas
RangeFormula
B1=COUNTIF(A1:A7,"00")
C1=COUNTIF(A1:A7,"<>00")
D1=A1="00"
E1=A1<>"00"
F1=COUNTA(A1:A7)-COUNTIF(A1:A7,"00")


D and E formulas copied down.
Looks like we can work around it by using something like F1 formula.
 
Last edited:
Upvote 0
Well, yes I am and I caught that after posting. Still does not correct the problem. Thanks
 
Upvote 0
Yes, jtakw, the F1 formula is my work around it but I don't like it as it is apart of a much larger formula.

Thanks!
 
Upvote 0
Well, here's another "workaround":


Book1
AFG
10033
210
300
420
511
600
700
Sheet338
Cell Formulas
RangeFormula
F1=COUNTA(A1:A7)-COUNTIF(A1:A7,"00")
G1=SUMPRODUCT(--(A1:A7<>"00"))
 
Upvote 0
Another option
=SUMPRODUCT(--(A1:A7<>"00"))

beaten2it
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,956
Messages
6,175,612
Members
452,660
Latest member
Zatman

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