(Solved) – Filtering table between 2 dates Excel VBA

  • by

I am attempting to filter a table in excel using VBA. I feel like I’m pretty close but for some reason its not displaying any data after it gets filtered. Here is a sample of what I am currently trying:

Dim Fiscal1 As Variant, Fiscal2 As Variant

Fiscal1 = ws2.Range("v13")
Fiscal2 = ws2.Range("W13")

x = MonthBox.ListIndex

Select Case x
    Case Is = 0
        ws.ListObjects("Table1").Range.AutoFilter Field:=3
 Case Is = 12
     ws.ListObjects("Table1").Range.AutoFilter Field:=3, Criteria1:=">= Fiscal1", Operator:= _
     xlAnd, Criteria2:="<= Fiscal2"

The values in the range cells are dates (11/25/2019 and 12/31/2019 respectively) and they are formatted as dates as well.

Leave a Reply

Your email address will not be published. Required fields are marked *