Does anyone know why this doesn't throw a Variable not defined
error when I compile it?
'Class1.cls'
Option Explicit
Public Sub foo()
ReDim fubar(1 To 2, 1 To 1)
End Sub
Am I misunderstanding how Option Explicit
is supposed to work? Or is there something wrong with this test? Or is this just a bug in VBA?
(I am testing this on Excel 2007)
From MSDN (http://msdn.microsoft.com/en-gb/library/y9341s4f%28v=vs.80%29.aspx)
"When Option Explicit appears in a file, you must explicitly declare all variables using the Dim or ReDim statements."
So ReDim works in Option Explicit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With