Formula to count the number of times a number appears

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.
Example.xlsx
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
If you could try the following in B2 copied down:

=IF(COUNTIF(A\$1:A1,A2)=0,MAX(B\$1:B1)+1,INDEX(B\$1:B1,MATCH(A2,A\$1:A1,0)))
Example.xlsx
0
Mechanical EngineerCommented:
A somewhat shorter formula that you can use in cell B2 and copy down is:
=IFERROR(VLOOKUP(A2,A\$1:B1,2,FALSE),MAX(B\$1:B1)+1)

If your real goal is to count how many different numbers are in column A, then consider:
=SUMPRODUCT(1/COUNTIF(A2:A15,A2:A15))
This formula requires that range A2:A15 not have any blank cells.
0
I think you might be looking to create a histogram.  Please see if the following tutorial suits your needs.

http://office.microsoft.com/en-us/excel-help/present-your-data-in-a-histogram-HA010342785.aspx
0
Author Commented:
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.
Example.xlsx
0
Mechanical EngineerCommented:
If you have Excel 2010 or later, you can use the AGGREGATE function:
Put the following formula in C3 (may be copied down):
=IFERROR(LOOKUP(999,C\$2:C2/((A\$2:A2=A3)*(B\$2:B2=B3))),AGGREGATE(14,6,(A\$2:A2=A3)*(C\$2:C2),1)+1)

Alternatively, you can array-enter the following formula in C3:
=IFERROR(LOOKUP(999,C\$2:C2/((A\$2:A2=A3)*(B\$2:B2=B3))),MAX((A\$2:A2=A3)*(C\$2:C2))+1)
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.
ExampleQ28240901.xlsx
0
Author Commented:
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?
0
Mechanical EngineerCommented:
brasiman,
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:
=IF(ISERROR(LOOKUP(999,C\$2:C2/((A\$2:A2=A3)*(B\$2:B2=B3)))),MAX((A\$2:A2=A3)*(C\$2:C2))+1,LOOKUP(999,C\$2:C2/((A\$2:A2=A3)*(B\$2:B2=B3))))

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.  :-)

ExampleQ28240901.xls
0

Experts Exchange Solution brought to you by