Loop gets stuck 2/3's in

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
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,224,564
Messages
6,179,548
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top