I have a dataset of 30k rows and 15 column.
I have set autofilter on column "O
" to select the cells contains string "x
" and delete all these rows.
the code takes a lot of time to finish (about 14 seconds) on a very power PC.
Is my code formulated well or there is a faster method to delete these filtered rows?
In advance, grateful for any helpful comments and answers.
Sub Macro1()
Dim ws As Worksheet, rng As Range, lastR As Long, lastC As Long
Set ws = ActiveSheet
lastR = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row 'Last Row on column 1
lastC = ws.Cells(1, ws.Columns.Count).End(xlToLeft).Column 'Last Column on Row 1
Set rng = ws.Range(ws.Cells(1, 1), ws.Cells(lastR, lastC))
ws.Rows("1:1").AutoFilter
rng.AutoFilter Field:=15, Criteria1:="x"
Intersect(ws.Cells, rng.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow).Delete
End Sub