Countif text not recognized

pleeseemailme

Board Regular
Joined
Dec 26, 2013
Messages
201
Howdy,

I have a report that spits out batches of information into a csv file. Before each batch, the report inserts the text: ">>>". I need to count the number of batches in each report, so I tried: =COUNTIF(A:A,">>>"). For whatever reason, this actually counts each cell with a value in it and not just the cells with ">>>". I've gotten around it by using the array formula: =SUM(IF(A:A=">>>",1,0)). However, I was curious if anyone could shed some light as to why the COUNTIF formula doesn't work; I'd like to learn why. Thank once again to you all.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Howdy,

I have a report that spits out batches of information into a csv file. Before each batch, the report inserts the text: ">>>". I need to count the number of batches in each report, so I tried: =COUNTIF(A:A,">>>"). For whatever reason, this actually counts each cell with a value in it and not just the cells with ">>>". I've gotten around it by using the array formula: =SUM(IF(A:A=">>>",1,0)). However, I was curious if anyone could shed some light as to why the COUNTIF formula doesn't work; I'd like to learn why. Thank once again to you all.

Consider:
FALSE
FALSE
<
FALSE
FALSE
>>>
FALSE
TRUE
s
TRUE
TRUE
x
TRUE
TRUE
3
FALSE
FALSE

<TBODY>
</TBODY>

[1] B1, copied down:

=A1 > ">>>"

[2] C1, copied down:

=A1 > "="&">>>"

[3]

=COUNTIF(A:A, ">>>")

===> 3

[4]

=COUNTIF(A:A,"="&">>>")

===> 1

COUNTIF behaves the same as D-functions...

If you want eliminate the effect of the > comparison operator, you need to invoke the COUNTIF formula with an = operator.

The behavior in [3] is copmparable with:

=COUNTIF(A:A, ">>")

or

=COUNTIF(A:A,">"&">")

or

=COUNTIF(A:A,">"&">>")

Conclusion: You need to neutralize the effect of the > operator.
 
Upvote 0
This is a guess.

The > is the operator greater than.

I think the COUNTIF function is interpreting this ">>>" as counting all cells as greater than ">>"
The first > is interpreted as an operator.

Try this instead
=COUNTIF(A:A,"=>>>")
 
Upvote 0
That did it. I just needed the "=" sign. It makes sense now that it was looking for cells greater than ">>". Thanks so much!
 
Upvote 0

Forum statistics

Threads
1,216,373
Messages
6,130,226
Members
449,567
Latest member
ashsweety

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