MamboKing
06-29-2008, 09:59 PM
I see this wieird behavior of ReDim in VBA.
I've a Public Vals_m#()
hence it should be visible everywhere in the module.
Executing the code I get: "Run Time Error 9 - Subscript out of range"
I understood that it's caused by a ReDim Vals_m(N)
This ReDim is instantiated into Sub1 that calls Sub2, both in the same module whith Public Vals_m#().
The error certainly occurs in Sub2 when I use Vars_m() first.
It really seems that the error is caused by the fact that Sub2 does not see the re-dimension of the array.
In fact, if I move ReDim Vals_m(N) into Sub2, the error disapperas!
Should't the ReDim of public array present the new dimensions everywhere in the Module?
I've a Public Vals_m#()
hence it should be visible everywhere in the module.
Executing the code I get: "Run Time Error 9 - Subscript out of range"
I understood that it's caused by a ReDim Vals_m(N)
This ReDim is instantiated into Sub1 that calls Sub2, both in the same module whith Public Vals_m#().
The error certainly occurs in Sub2 when I use Vars_m() first.
It really seems that the error is caused by the fact that Sub2 does not see the re-dimension of the array.
In fact, if I move ReDim Vals_m(N) into Sub2, the error disapperas!
Should't the ReDim of public array present the new dimensions everywhere in the Module?