Finding unique entries in a column

B

Bob

I have a range of cell entries,

Worksheets(Sheet1Name).Range(Cells(Sheet1FirstRowNum, _
Sheet1RespCodeColPointer) & ":" & Cells(Sheet1LastRowNum, _
Sheet1RespCodeColPointer))

in which I need to:

1) count the number of unique entries and store the result in a variable

2) copy each of the unique entries that were found to an array, and then
refer to each entry in the array in a subsequent formula

Any help in showing me how to perform these 2 steps would be greatly
appreciated. Thanks.
 
J

Joel

You don't need VBA to perform this task

If your numbers arre in column A starting in row 1, then put 1 in cell B1.
the first number is always unique. In cell B2 put in the following formula
=IF(COUNTIF(A$1:A1,A2)=0,1,0)
Notice the $1.
Copy this formula to other cells in column B. The values in column B witth
a 1 is the unique numbers. You can SUM column b to get the number of unique
numbers.

I can show you how to do this in VBA if you don't want to do it in a
spreadsheet formula.
 
B

Bob

Joel,

Thanks for your suggestion, but I really need to perform the task in VBA
using the range:

Worksheets(Sheet1Name).Range(Cells(Sheet1FirstRowNum, _
Sheet1RespCodeColPointer) & ":" & Cells(Sheet1LastRowNum, _
Sheet1RespCodeColPointer))

Thanks again,
Bob
 
B

Bob

Bernd,

Thanks for the URL! I will take a look at your UDF to see if it meets my
needs.

Thanks again,
Bob
 
B

Bob

Dave,

Thanks for the URL to John Walkenbach's solution. I will take a look at it
to see if it meets my needs.

Thanks again for all your help,
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top