Delete Rows that do not contain
Give this macro a try, just set the 3 constant (Const) statements at the
beginning to match your actual set up...
Sub RemoveNotCurrentRecords()
Dim X As Long
Dim LastRow As Long
Dim OriginalCalculationMode As Long
Dim RowsToDelete As Range
Const DataStartRow As Long = 2
Const TestColumn As String = "A"
Const SheetName As String = "Sheet1"
On Error GoTo Whoops
OriginalCalculationMode = Application.Calculation
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
With Worksheets(SheetName)
LastRow = .Cells(.Rows.Count, 1).End(xlUp).Row
For X = LastRow To DataStartRow Step -1
' <<Set your test condition here
If UCase(.Cells(X, TestColumn).Value) = "T75TA" Then
If RowsToDelete Is Nothing Then
Set RowsToDelete = .Cells(X, TestColumn)
Else
Set RowsToDelete = Union(RowsToDelete, .Cells(X, TestColumn))
End If
If RowsToDelete.Areas.Count 100 Then
RowsToDelete.EntireRow.Delete xlShiftUp
Set RowsToDelete = Nothing
End If
End If
Next
End With
If Not RowsToDelete Is Nothing Then
RowsToDelete.EntireRow.Delete xlShiftUp
End If
Whoops:
Application.Calculation = OriginalCalculationMode
Application.ScreenUpdating = True
End Sub
--
Rick (MVP - Excel)
"SITCFanTN" wrote in message
...
I want to create a macro that will run through 10,000 plus rows and quickly
delete all rows if Col A does not contain the text of T75TA. Any help
you
can provide is greatly appreciated, thank you.
|