When this macro runs off of a button on an excel vba form, filter does not work
>=1/1/2016
should change the filter to only show dates >= Jan 1 2016, but it does not work.
The table data comes in as a date field, but excel does not format the data as a date formate until after I refresh it and change that column to Date format from General. So the dates are in 2016-01-01 format from sql and the filter does not work.
If in SQL I change the date to a text variable as 01/01/2016 it still does not filter.
>=1/1/2016
should change the filter to only show dates >= Jan 1 2016, but it does not work.
The table data comes in as a date field, but excel does not format the data as a date formate until after I refresh it and change that column to Date format from General. So the dates are in 2016-01-01 format from sql and the filter does not work.
If in SQL I change the date to a text variable as 01/01/2016 it still does not filter.
Code:
Private Sub CommandButton3_Click()
Dim msgboxAnswer As Integer
ws = ActiveSheet.Name
msgboxAnswer = MsgBox("Dates correct " & DateLeft & " " & DateRight & "?", vbYesNoCancel)
If msgboxAnswer = 6 Then
'Answer = 6(Yes)
If ws = "Incentives Sanctions" Then
Sheet8.ListObjects("Table_Query_Incentives_Sanctions").Range.AutoFilter Field:=3, Criteria1:=">" & DateLeft
End If
End If
'Debug.Print DateLeft
'Debug.Print DateRight
End Sub