View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Bill Kuunders Bill Kuunders is offline
external usenet poster
 
Posts: 303
Default Display unique values in a range.

Or you could go to <data<filter<advanced filter select "copy to another
place" and
tick "unique records."

regards
Bill K

"Bob Phillips" wrote in message
...
Here's a simple macro to do this

Dim cLastRow As Long
Dim i As Long
Dim j As Long
Dim prevVal

cLastRow = Cells(Rows.Count, "A").End(xlUp).Row
prevVal = ""
For i = 1 To cLastRow
If Cells(i, "A").Value < prevVal Then
j = j + 1
Cells(j, "B").Value = Cells(i, "A").Value
prevVal = Cells(i, "A").Value
End If
Next i

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"future" wrote in message
om...
I am looking for a procedure that will

loop through items in a range, and return the unique items starting in
a target cell.

Range 1
2
2
2
3
4
5
3
4


Range 2
2
3
4
5


such that when I run the macro each item in Range 1 is looked at until
Range 1 =" ". The result being Range 2.