Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88054

Option Explicit does not see one undeclared variable, but works for other

$
0
0

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

Viewing all articles
Browse latest Browse all 88054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>