Bloody annoying US dates again, this one I've not seen a solution on my many, many searches.
I have a bit of VBA I found that pulls in data from some htm files generated by our business partner in Detroit:
Dim DirPath As String
Dim I_Row As Integer
Dim FilePath As String
Dim xCount As Long
DirPath = ipsosFolder
If DirPath = "" Then Exit Sub
Application.ScreenUpdating = False
FilePath = Dir(DirPath & "\*.htm")
Do While FilePath <> ""
With ActiveSheet.QueryTables.Add(Connection:="URL;" _
& DirPath & "\" & FilePath, Destination:=Range("A1"))
.Name = "a"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = True
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
FilePath = Dir
End With
Loop
(Note the .WebDisableDateRecognition = True, that was my first hope at fixing this, have Excel ignore the americanised dates until I could do something to fix them.)
So there's dates in here formatted in the US way - 09/21/2022 for today, for example. Now, this particular date is of no concern as here in Australia, it's invalid, there is no 21st month and I can easily fix this up with a quick =RIGHT(LEFT(B2,5),2)&"/"&LEFT(B2,2)&"/"&RIGHT(B2,10) but my problem comes in when we get to dates like 09/12/2022 as there is a 9th of December as well as 12th of September and Excel, very kindly, converts this to a date integer which breaks the above code as the left / right is no longer referencing 09/12/2022 but 44904.
Anyone with a suggestion on what I can do stop Excel "helping" and converting the dates to an American interpretation - I've been over the machine and double checked all the windows settings are for the correct date format here.
The big issue is I need to compare these dates against some dates we have pulled in from another dataset that're in the "proper" format of d/m/y and not m/d/y like only the Americans seem to insist on using, so need to retain them as dates and accurate = \