View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz[_2_] JLGWhiz[_2_] is offline
external usenet poster
 
Posts: 1,565
Default delete entire row with condition

If the file is sorted on column A so that all duplicates are grouped, then:

Sub dups()
Dim lr As Long, sh as Worksheet
Set sh = ActiveSheet
lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
For i = lr To 2 Step -1
If sh.Cells(i, 1) = sh.Cells(i - 1, 1) Then
Rows(i).Delete
End If
Next
End Sub

The file m8ust be sorted first for the macro to work.


"Anna" wrote in message
...
I would like to have a macro that scan a column (i.e. column a). Under the
scanned column, the entired row of any duplicate cell will be deleted.
(i.e.
cell a5=abc, cell a6, a7=abc, row a6 and a7 will be deleted). Anyone can
give
me a big hand?
Thank you so much.