Thijsk
Thijsk

Reputation: 103

Excel VBA autofilter uncheck/exclude items

quick question, how can I exclude an item in a list through VBA. Have been working on a sheet that automatically prints out a list without a certain date on it.

   Rows("2:2").Select
    Selection.AutoFilter
    ActiveSheet.Range("$A$3:$H$1000").AutoFilter Field:=3, Criteria1:="Hans"
    ActiveSheet.Range("$A$3:$H$1000").AutoFilter Field:=7, Criteria1:="open"
    ActiveSheet.Range("$A$3:$H$1000").AutoFilter Field:=6, Criteria1:="<>1/0/1900", Operator:=xlFilterValues
      ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
     IgnorePrintAreas:=False
         Rows("3:3").Select
    Selection.AutoFilter

Problem is that the criteria does not work with the date 0-1-1900 to filter it out. What am I doing wrong?

Upvotes: 0

Views: 16155

Answers (1)

Musisold
Musisold

Reputation: 131

0-1-1900 is a date that does not exist. This might be the problem.

Just use

Criteria1:=">1/1/1900" 

and it should word fine.

Upvotes: 1

Related Questions