Rubberduck
Rubberduck copied to clipboard
unexpected "Variable is used but not assigned" on array after ReDim
Version 2.5.2.5906 OS: Microsoft Windows NT 10.0.22000.0, x64 Host Product: Microsoft Office x64 Host Version: 16.0.15225.20288 Host Executable: EXCEL.EXE
I get two unexpected "Variable is used but not assigned" errors in this code:
Sub TEST()
Dim i, arr
ReDim arr(2)
arr(0) = Array("aaa", "bbbb")
arr(1) = Array("ccc", "dddd")
arr(2) = Array("eee", "ffff")
For i = LBound(arr) To UBound(arr) ' I get two "Variable 'arr' is used but not assigned." here
'...
Next
End Sub
I don't get the errors if I declare the array as fixed size without ReDim.