Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counting distinct entries in a range in excel

Status
Not open for further replies.

amberH

Programmer
Jun 10, 2002
36
0
0
CA
Hi all,

I found a formula on a web page for counting distinct entries in a range of cells in Excel. It works on one of my worksheets but not on another. I'm baffled.

The following formula I use in one sheet and it works great:

=SUM(IF(COUNTIF(C11:C1000,C11:C1000)=0,"",1/COUNTIF(C11:C1000,C11:C1000)))

it counts all unique values in the column.
Now I'm trying to do the same for a range as follows:

=SUM(IF(COUNTIF(AV21:BA29,AV21:BA29)=0,"",1/COUNTIF(AV21:BA29, AV21:BA29)))

and I get 'error #VALUE'.
The example I found on the web page ( uses a similar range in it's example:

=SUM(IF(COUNTIF(A1:D100,A1:D100)=0,"",1/COUNTIF(A1:D100,A1:D100)))

Does anyone have any idea why my 2nd formula won't work??
I'm baffled!
Cheers,
amber
 
Use an array formula to perform the calculation. If i understand array formulas correctly, becaue you are covering a range, you will need to do a CTRL-SHIFT-ENTER (I have tested the formula and it works in array form).

This is the same even if the range was defined.

Hope that makes sense.
 
I was thinking about your question and as long as there are no gaps (spaces etc), this formula as an array will work too:

=SUM(1/COUNTIF(AV21:BA29,AV21:BA29))

Note, do a CTRL-SHIFT-ENTER.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top