Formula to count the number of times a number appears

Posted on 2013-09-16
Medium Priority
Last Modified: 2013-09-19
I have a spreadsheet and need help on a formula. In column A, there are lots of random numbers, many of which repeat. In column B, I am trying to figure out a formula that will count how many different numbers are there. COUNTIF won't work. Please see the attached spreadsheet as an example. Its hard to explain, the spreadsheet will make more sense.
Question by:brasiman
LVL 24

Assisted Solution

Steve earned 200 total points
ID: 39497028
If you could try the following in B2 copied down:

LVL 81

Expert Comment

ID: 39497157
A somewhat shorter formula that you can use in cell B2 and copy down is:

If your real goal is to count how many different numbers are in column A, then consider:
This formula requires that range A2:A15 not have any blank cells.
LVL 14

Expert Comment

ID: 39500815
I think you might be looking to create a histogram.  Please see if the following tutorial suits your needs.

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.


Author Comment

ID: 39504949
Thanks for the quick answers, both byundt and the_barman worked great. As i started typing the formula in though. They added one column on me, and its a unique identifier. See the example and it will probably make more sense. I basically need the same thing, but i need the count to start over on every unique ID.
LVL 81

Expert Comment

ID: 39505836
If you have Excel 2010 or later, you can use the AGGREGATE function:
Put the following formula in C3 (may be copied down):

Alternatively, you can array-enter the following formula in C3:
To array-enter a formula, click in the formula bar, hold Control and Shift keys down, then hit Enter.

With either approach, put a 1 in cell C2.

Author Comment

ID: 39506950
Thanks byundt. I tried it and i'm getting the #NAME? error. i checked the formula and its correct. I tried your alternative approach. i am using excel 2003. any thoughts/ideas?
LVL 81

Accepted Solution

byundt earned 1800 total points
ID: 39507002
The IFERROR function requires Excel 2007 or later. That's why you are getting #NAME? error.

For Excel 2003 and earlier, you can copy down a longer array-entered formula in cell C3:

To array-enter a formula, click in the formula bar, hold Control and Shift keys down, then hit Enter. If you see #VALUE! errors when you copy the formula down, then you didn't array-enter the formula.

For future reference, it is always good to specify your software version when you ask an Excel question on Experts Exchange. I've got six different versions of Excel installed on my laptop so I can reproduce what you are seeing and respond appropriately for your version of Excel. Many Askers use the Tags to list their software version.  :-)


Author Comment

ID: 39507108
Brad, you're awesome, thank you! That worked. Good point on specifying the version. Makes sense. My bad on that one. Next time i'll make sure I do that. Thanks again for your help!

Author Closing Comment

ID: 39507111
Great suggestions and quick responses, thank you!

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
What to do if a split doesn't fit? Or a bunch of invoice lines must be rounded while the sum must match a total? It takes a little, but - when done - it is extremely easy to implement.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question