> You can use multiple columns and get a list of unique combinations of those
> columns.
[quoted text clipped - 24 lines]
>
> - Show quoted text -
I got this base code from a posting but have butchered it and can't
find the original post again. I don't really understand it so not sure
if it's even close to what I want to do. I want all occurances of
where the first and last names are the same to be highlighted please
and placed at the top of the s/s. I don't want to concatenate and
advance filter as I want to be able to quickly search all records when
deciding which duplicate to delete or to keep both/all (other columns
may differ).
Sub ShowPetaHerDuplicates()
'Application.ScreenUpdating = False
Range("a:a").EntireColumn.Insert
Range("a1").Value = "Key"
Range("b1").Value = "Count"
Range("a2").FormulaR1C1 = "=RC[5]&RC[6]"
Range("b2").FormulaR1C1 = "=COUNTIF(C[-1],RC[-1])"
Range("a2:b2").AutoFill _
Destination:=Range("e2:f2" & Range("C65536").End(xlUp).Row)
Range("b:b").AutoFilter Field:=1, Criteria1:=">1"
If Range("b1").CurrentRegion.Columns(2).SpecialCells _
(xlCellTypeVisible).Cells.Count > 1 Then
Application.ScreenUpdating = True
MsgBox "There are duplicated values"
Else
Range("a:b").EntireColumn.Delete
Application.ScreenUpdating = True
MsgBox "There were no duplicated values"
End If
End Sub
thanks a lot
Peta
Dave Peterson - 13 Mar 2008 15:30 GMT
I don't see where you tried the .advancedfilter technique.
But this seemed to work ok for me:
Option Explicit
Sub testme01()
Dim myRng As Range
Dim wks As Worksheet
Dim TotalRows As Long
Dim HowManyVisibleRows As Long
Set wks = ActiveSheet
With wks
Set myRng = .Range("C1:d" & .Cells(.Rows.Count, "C").End(xlUp).Row)
TotalRows = myRng.Columns(1).Cells.Count
If .FilterMode Then
.ShowAllData
End If
myRng.AdvancedFilter _
Action:=xlFilterInPlace, Unique:=True
HowManyVisibleRows = myRng.Columns(1).Cells _
.SpecialCells(xlCellTypeVisible).Cells.Count
If .FilterMode Then
.ShowAllData
End If
End With
If TotalRows <> HowManyVisibleRows Then
MsgBox "Duplicates"
Else
MsgBox "No duplicates"
End If
End Sub
This assumes that there are headers in row 1 so that advancedfilter can work ok.
> > You can use multiple columns and get a list of unique combinations of those
> > columns.
[quoted text clipped - 57 lines]
> thanks a lot
> Peta

Signature
Dave Peterson