Counting Duplicates in a list...how does this formula work???

imaguy77

New Member
Joined
Aug 26, 2008
Messages
21
This formula will count duplicates in a list. If you have a list that says:

eggs
eggs
beef
beef
beef
chicken

the formula will return:

2
2
3
3
3
1

because thats the number of instances of each unique item.

here's the formula:

=COUNTIF($A$1:$A$10,$A$1:$A$10&"")

but i can't figure out HOW this works. can someone explain it please? Thanks!!!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
You really don't need the second part of the COUNTIF to be a range. Just using A1 will work as it will change as you copy it down. It works, because at the end of the statement you are comparing, for example, A1 to A1&"" which is just A1 with a null value appended. Apparently Excel calls this a different value than just plain A1 so a circular reference is avoided. Clever actually...nice formula.

So, formula could be as follows and still work:
=COUNTIF($A$1:$A$10,A1&"")
 
Last edited:
Upvote 0
The difference between

=COUNTIF(A$1:A$10,A1&"")

and

=COUNTIF(A$1:A$10,A1)

is the way that blank cells are treated. The former will actually count the blank cells, the latter will return a zero against each blank cell, no matter how many there are
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,466
Members
449,086
Latest member
kwindels

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