Reputation: 275
I am currently trying to unselect the current month using VBA I know how to select just the current month using VBA (the code is below) but I don't know how to unselect the current month while leaving the other months on.
Sheets("Sheet1").Range("d1:d6").AutoFilter Field:=4, Criteria1:=xlFilterThisMonth, Operator:=xlFilterDynamic
Upvotes: 1
Views: 1358
Reputation: 29332
Try this:
Sheets("Sheet1").Range("d1:d20").AutoFilter Field:=1, Operator:=xlOr, _
Criteria1:="<=" & Application.EoMonth(Date, -1), _
Criteria2:=">" & Application.EoMonth(Date, 0)
Note:
EoMonth(Date, 0)
marks the last day of current month
EoMonth(Date, -1)
marks the last day of previous month
Upvotes: 1
Reputation: 71
Maybe you first try to deselect the filter
Cells.AutoFilter
Then you select all the other months
Upvotes: 0