Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VBA Autofilter not equal to

Sub Macro1()
‘Remove all except validated
ActiveSheet.Range("$A$1:$H$5202").AutoFilter field:=8, Criteria1:<>"Validated"

Activesheet.Range("$A$2:$O$99999").SpecialCells(xlCellTypeVisible).Select
Selection.EntireRow.Delete

ActiveSheet.ShowAllData
 End sub

How to replace "not equal than" in VBA? <> does not work.

like image 383
chee seng ng Avatar asked Dec 14 '22 13:12

chee seng ng


1 Answers

If you want your filter criteria to exclude "Validated", then try changing this line:

ActiveSheet.Range("$A$1:$H$5202").AutoFilter field:=8, Criteria1:<>"Validated"

to

ActiveSheet.Range("$A$1:$H$5202").AutoFilter field:=8, Criteria1:="<>Validated"

Note that the = in Criteria:= doesn't have anything to do with your filter criteria. (It relates to VBA and how you provide an argument to a named parameter.)

like image 80
chillin Avatar answered Dec 30 '22 19:12

chillin