FryGirl
Well-known Member
- Joined
- Nov 11, 2008
- Messages
- 1,362
- Office Version
- 365
- 2016
- Platform
- Windows
I have a worksheet with which fills at almost 300k rows and out to column AA. I need to delete all the 2014 records which are about 53k. I've used a macro to filter by column A and used the notoriously slow looping, but both of these lockup and or after ten minutes I stopped the macro. I'm using a test sheet to see if I can get this working, but of course will have to do this on the real workbook when done. Here is what I tried. Any suggestions.
VBA Code:
Sub Del2014()
Dim LR As Long, i As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
TurnEverythingOff
On Error GoTo Skip
For i = LR To 1 Step -1
If Range("A" & i).Value = 2014 Then Rows(i).Delete
Next i
Skip:
TurnEverythingOn
End Sub
VBA Code:
Sub TurnEverythingOff()
With Application
.Calculation = xlCalculationManual
.EnableEvents = False
.DisplayAlerts = False
.ScreenUpdating = False
End With
End Sub
VBA Code:
Sub TurnEverythingOn()
With Application
.Calculation = xlCalculationAutomatic
.EnableEvents = True
.DisplayAlerts = True
.ScreenUpdating = True
End With
End Sub