Excel 2016 on Windows 10.
I have some code which filters the data in a worksheet by date. The date is entered into a user form and populates a date variable. The date format is: dd/mm/yyyy
When I activate the autofilter in the code, it reads the date as US format and therefore does not display any data.
I have checked that all relevant regional settings in MS Office and Windows are set to UK English with the appropriate date formats.
This is the code that assigns the date variable:
'=====
'=====
The user enters something like: 07/11/2017 (for 7th November 2017)
This is the code that activates the autofilter:
'=====
'=====
If I break into the code just after the autofilter is activated and check the filter properties in the worksheet it shows a date filter value of: 11/7/2017
I would be grateful for any ideas you may have to resolve this.
I have some code which filters the data in a worksheet by date. The date is entered into a user form and populates a date variable. The date format is: dd/mm/yyyy
When I activate the autofilter in the code, it reads the date as US format and therefore does not display any data.
I have checked that all relevant regional settings in MS Office and Windows are set to UK English with the appropriate date formats.
This is the code that assigns the date variable:
'=====
Code:
Dim ReportDate As Date
ReportDate = TextBox1.Value
The user enters something like: 07/11/2017 (for 7th November 2017)
This is the code that activates the autofilter:
'=====
Code:
For i = 1 To 24
With ActiveSheet.Range("A1:" & LastData)
.AutoFilter Field:=1, Criteria1:=ReportDate
.AutoFilter Field:=2, Criteria1:=i
End With
' Do some other stuff...
Next i
If I break into the code just after the autofilter is activated and check the filter properties in the worksheet it shows a date filter value of: 11/7/2017
I would be grateful for any ideas you may have to resolve this.