Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I'm trying to apply a filter to a date column in my database, but the results are empty. Is someone able to suggest a correction to my code?
The value changeDate = 2022-07-22, is a date, and can be accurately reformatted as 22-Jul-22 ("dd-mmm-yy").
The data in column A of worksheet wsSS are dates, represented as serials of that date. They can be accurately reformatted as "dd-mmm-yy".
In my testing, with changedate = 2022-07-22, the filter is not filtering out the row (72) in which A72 = 44764 (2022-07-22).
Code:
Sub StaffOnChange()
Dim nWSName As String
Dim wsSS As Worksheet
Dim changeDate As Date
nWSName = ActiveSheet.Name
Set wsSS = Worksheets(nWSName)
changeDate = wsHold.Range("B3")
With wsSS
If .AutoFilterMode Then .AutoFilterMode = False
.Range("B3").AutoFilter Field:=1, Criteria1:=changeDate
.AutoFilterMode = False
End With
wsSS.Delete
End Sub
The value changeDate = 2022-07-22, is a date, and can be accurately reformatted as 22-Jul-22 ("dd-mmm-yy").
The data in column A of worksheet wsSS are dates, represented as serials of that date. They can be accurately reformatted as "dd-mmm-yy".
In my testing, with changedate = 2022-07-22, the filter is not filtering out the row (72) in which A72 = 44764 (2022-07-22).