jawaharprm
Member
Hi Team,
Pls help on clear this macro
trying to filter between <=-50 to <=-5, if once selected i need to delete the entire row.
But iam getting error "Object Variable or with block variable not set"
enclosed sample file for reference.
Pls help on clear this macro
trying to filter between <=-50 to <=-5, if once selected i need to delete the entire row.
But iam getting error "Object Variable or with block variable not set"
enclosed sample file for reference.
Code:
Option Explicit
Sub filter1()
Dim ws As Worksheet
Dim LR As Long
ws.Range("A1:M").AutoFilter Field:=12, Criteria1:=">=-50", Operator:=xlAnd, Criteria2:="<=-5"
ws.Range("A2.M" & LR).Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End Sub
Sub filter2()
Dim ws As Worksheet
Dim LR As Long
ws.Range("A1:M").AutoFilter Field:=12, Criteria1:=">=5", Operator:=xlAnd, Criteria2:="<=50"
ws.Range("A2.M" & LR).Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End Sub