Struggling with something that should be simple! I am trying to filter a sheet containing dates to show only one date, a variable created from an input box. Whatever I try, and however I define the variable, it results in nothing...
Here is my code:
Sub Filter()
Dim TheDate As Double ' I have tried Long, Date, Integer....
Dim rRange As Range
Set wb2 = Workbooks("JADATA.xlsm") 'To set the workbook
wb2.Sheets("Employee Hours").Activate
If Sheets("Employee Hours").FilterMode = True Then
Sheets("Employee Hours").ShowAllData
End If
TheDate = 44888 'this is the date, 23/11/2022, to test
With Worksheets("Employee Hours")
Set rTemp = .Range(.Cells(1, 1), .Cells(.Rows.Count, 7).End(xlUp))
End With
With rTemp
.AutoFilter field:=1, _
Criteria1:="=" & CDbl(TheDate) 'Tried without "=" &; and without CDbl...
End With
End Sub