Trevasaurus
New Member
- Joined
- Dec 4, 2012
- Messages
- 13
I have this code for comparing two columns, finding repeated entries, and deleting the row where the entry is repeated. I've tested it on a small data base (<50 entries) and it works. However, when I apply it to a larger database (>300), I'm getting an error: "Subscript Out of Range"
Sub find_copy01()
Dim c2 As Range, c As Range
With Sheets("Sheet2")
LR = .Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For Each c2 In .Range("A1:A" & LR)
Set c = Sheets("Sheet1").Columns(1).Find(c2, , xlValues, xlWhole)
If Not c Is Nothing Then
c.EntireRow.Interior.Color = vbRed
c2.EntireRow.Delete
End If
Next c2
End With
End Sub
Can anyone tell me what is wrong?
Sub find_copy01()
Dim c2 As Range, c As Range
With Sheets("Sheet2")
LR = .Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For Each c2 In .Range("A1:A" & LR)
Set c = Sheets("Sheet1").Columns(1).Find(c2, , xlValues, xlWhole)
If Not c Is Nothing Then
c.EntireRow.Interior.Color = vbRed
c2.EntireRow.Delete
End If
Next c2
End With
End Sub
Can anyone tell me what is wrong?