For line with Debug.Print
everything works fine, meaning Option Explicit
catches an error and displays a pop-up about an undefined variable.
However, if I remove the Debug.Print
line, which I added to see if Option Explicit
works at all, code successfully executes. Compile is successful as well. It should not be, as there is a typo, "vDailBuys" instead of "vDailyBuys" in the 2nd ReDim
statement.
Why isn't this typo detected?
I use the 2nd ReDim
to clear array contents, nut sure if it is recommended way, but it works like a charm.
Option Explicit
Option Base 1
Sub test()
Dim vDailyBuys() As Variant
ReDim vDailyBuys(1, 10)
ReDim vDailBuys(1, UBound(vDailyBuys, 2)) As Variant
Debug.Print abcde
End Sub