I am new to VBA. Trying to filter one column with value starts with 42 and 48 and delete rows, but there is error message 'Application defined or object defined error'. Can anyone help on this? Tq
Sub FilterDeleteVisible() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("DO") Call FilterAndDelete(ws, "E", "42*", "48*") End SubSub FilterAndDelete(ws As Worksheet, col As String, ParamArray criteria() As Variant) Dim rng As Range Dim MyArray As Variant MyArray = criteria Set rng = ws.Range(col & ":" & col) rng.AutoFilter Field:=1, Criteria1:=MyArray, Operator:=xlFilterValues rng.Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete ws.AutoFilterMode = FalseEnd Sub