I recently changed my regional setting on Win 10 and this affected how my VBA macros interpret dates and my Range.Find() stopped working correctly.
Below is example of simple macro that is used to return row of a date.
Sub a()
Dim dt_start As Date
dt_start = #11/6/2021# ' 11 Jun 2021
Dim rDateColumn As Range
Set rDateColumn = ThisWorkbook.Worksheets("2").Range("A:A")
rDateColumn.NumberFormat = "dd/mm/yyyy"
w = rDateColumn.Find(What:=Format(dt_start, "dd/mm/yyyy"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows).Row
End Sub
When i try to run it it returns
Run-time error '91':.
I also tried this code with
lookIn:=xlValues
Even though I set date format to "dd/mm/yyyy" VBA still reads it as "mm/dd/yyyy". See below screenshot.
I tried to convert the dt_start to string (Format(dt_start, "dd/mm/yyyy") and then back to date DateValue(str_date), however I am getting back I am getting "06/11/2021" which is 6 Novemeber 2021.
Below are my system regional settings:
and Excel date settings.
Any info much appreciated. Thanks!



What:=Format(dt_start, "dd/mm/yyyy")searches for a string but if your dates are real numeric dates that does not work, then you need to search for the numeric value. Convert your date into a double and serach for thatWhat:=CDbl(dt_start). Numeric dates are saved in cells as double. Where the number is the amount of days since1900-01-01this way you can calculate with dates and format them with number format into any look you want.What:=DateSerial(2021,6,11)to create your search date from year, month, day: this is unambiguous, no matter what your regional settings are. Also, are you sure you don’t want to searchLookIn:=xlValues?.NumberFormatsetting only changes how the data appears, not how it is stored. Do this on cell A4 in your picture to check whether you have a ‘real’ Excel date.