postelrich
New Member
- Joined
- Feb 24, 2011
- Messages
- 31
I am trying to delete rows off a master sheet based if it already exists on two other sheets. This sheet has 14000 rows of data on it, and I already successfully deleted the duplicate data from the first sheet which had about 750 rows. Now when I try to do the second sheet which has about 8000 rows, its gets to about the 5000th and then gets stuck in a loop. Even if I break from it and step forward manually, hit run, it still gets stuck. Any clues as to why?
Code:
Option Explicit
Sub RowDelete()
Dim c As Range
Dim rRange As Range
Dim oRange As Range
Dim x
Set rRange = Sheets("clean").Range("J2:J8063")
Set oRange = Sheets("master").Range("A1:BY13542")
For Each c In rRange
On Error Resume Next
x = c
oRange.AutoFilter Field:=1, Criteria1:=x
'oRange.Offset(1, 0).SpecialCells("xlCellTypeVisible).Copy Destination:= Sheets("Deleted").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
oRange.Offset(1, 0).SpecialCells(xlCellTypeVisible).Select
Selection.Copy Sheets("Deleted").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
'oRange.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
Application.DisplayAlerts = False
Selection.Delete
Application.DisplayAlerts = True
oRange.AutoFilter
On Error GoTo 0
Next c
End Sub