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

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,210
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.
 

AlphaFrog

MrExcel MVP
Joined
Sep 2, 2009
Messages
16,451
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,"=>>>")
 

pleeseemailme

Board Regular
Joined
Dec 26, 2013
Messages
201
That did it. I just needed the "=" sign. It makes sense now that it was looking for cells greater than ">>". Thanks so much!
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,826
Messages
5,855,863
Members
431,771
Latest member
CoryMelth

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
Top