The string "aug11" is not a valid Excel date format according to IsDate() because the function returns "False". However, when the test code segment below is executed, Excel thinks it is a date despite returning False, because "aug11" is being converted to a date of "11-Aug" represented by "8/11/2021" (see value in Cell A1). Cell A1 should contain the string "aug11".
How can this be avoided? I need to test a variety of date formats to properly use them or not in other code. According to IsDate(), "aug11" should be a string but Excel does not treat it that way.
Help please.
How can this be avoided? I need to test a variety of date formats to properly use them or not in other code. According to IsDate(), "aug11" should be a string but Excel does not treat it that way.
Help please.
VBA Code:
Sub DateTest()
Dim sDate As String, bTest As Boolean
Range("A1").Value = vbNullString
sDate = "aug11"
bTest = IsDate(sDate)
MsgBox "String 'aug11' is a valid date format: " & bTest
Range("A1").Value = sDate
End Sub