Hi i have the below code which runs on deleting duplicate code which i found in an excel manual. I am having some trouble as i want to convert the code so that it will run on all worksheets i have which are numbered such as 1,2,3,4 etc.
This is so it makes the workbook easy maintenance for when deleting or adding worksheets which happens quite regularly.
Thanks
Sub Delete_Duplicate_Rows()
'
Dim str1 As String, str2 As String
Dim r1 As Long, r2 As Long, c As Long
'
Application.ScreenUpdating = False
With Sheets("1").UsedRange
'
For r1 = .Rows.Count To 2 Step -1
str1 = ""
For c = 1 To .Columns.Count
str1 = str1 & Cells(r1, c).Value
Next c
For r2 = r1 - 1 To 1 Step -1
str2 = ""
For c = 1 To .Columns.Count
str2 = str2 & Cells(r2, c).Value
Next c
If str1 = str2 Then
Rows(r1).Delete
Exit For
End If
Next r2
Next r1
'
End With
Application.ScreenUpdating = True
End Sub
Bookmarks