View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
KK KK is offline
external usenet poster
 
Posts: 61
Default Delete duplicates?

I have the following code below. How can I include sheet "customers2" also in
the code?

Private Sub CommandButton99_Click()

Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long

With Worksheets("Customers")
FirstRow = 2 'headers in row 1
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row

For iRow = FirstRow To LastRow Step 1
If Application.CountIf(.Range("a1").EntireColumn, _
.Cells(iRow, "A").Value) 1 Then
'it's a duplicate
.Rows(iRow).Delete
End If
Next iRow
End With

Unload Me

End Sub

thank you
--
kk