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?
 
COUNTIF(S) reads text numbers and real numbers as numbers by default (as designed) and a string of 0's default also to a 0.


If you want to read text 0 or a string of 0's as text, better to switch to formulas with functions which do not have the foregoing default behavior.
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
If you want to read text 0 or a string of 0's as text, better to switch to formulas with functions which do not have the foregoing default behavior.
Given the OP's data, is there any problem with using the asterisk solution I hit upon in Message #16 ?
 
Last edited:
Upvote 0
Given the OP's data, is there any problem with using the asterisk solution I hit upon in Message #16 ?

[0]
=COUNTIF(A1:A7,"<>00*")

would behave the same way as

[1]
=COUNTA(A1:A7)-COUNTIF(A1:A7,"00")

[2]
=SUMPRODUCT(--(A1:A7<>"00"))

[3]
=SUM(COUNTIFS(A1:A7,{"?*","00"})*{1,-1})

The latter, i.e. [3], would exclude any non-text.

So, if the intent is counting all kind of values except 00 (or 000), [0], that is, the suggestion you made, will do. By the way, 00* means TEXT starting with 00, hence the desired effect.
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,629
Members
452,661
Latest member
Nonhle

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