Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this code only looks to see if a value is unique to its previous value.
any way to see if it is unique to all previous values? Sub Unique() 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 End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try this
Sub Unique() Dim cLastRow As Long Dim i As Long Dim j As Long Dim prevVal Dim c As Range cLastRow = Cells(Rows.Count, "A").End(xlUp).Row prevVal = "" For i = 1 To cLastRow Set c = Worksheets("Sheet2").Columns("B").Find(Cells(i, "A")) If c Is Nothing Then j = j + 1 Worksheets("Sheet2").Cells(j, "B").Value = Cells(i, "A").Value prevVal = Cells(i, "A").Value End If Next i End Sub -- 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... this code only looks to see if a value is unique to its previous value. any way to see if it is unique to all previous values? Sub Unique() 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 End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Display only unique values in CONCATENATE formula | Excel Discussion (Misc queries) | |||
Display Unique Values | Excel Worksheet Functions | |||
Display Unique Values Question | Excel Worksheet Functions | |||
count and display unique values | Excel Worksheet Functions | |||
Modifying a Formula To display only Unique Values | Excel Worksheet Functions |