|
subscript out of range error 9
hii there,
in vba i declared an array dim x1(0 to 10) as variant
and now am trying to assign a value to x1(0) = 0
its showing me the following error:
subscript out of rnage error 9
any suggestions
thx
vishal patel
not sure why that would be an issue but why are you bothering declaring it that way when dim x1(10) would do exactly the same thing with less typing.
bare in mind x1(10) gives an array of 11 items (zero-based), and to check your array range just debug the program and step through the code after you declare it and add a watch to see what size it is
also, check that your code does not have the option base set to 1 instead of 0 as this will start arrays at 1 not 0 hence out of range. to be on the safe side you can place the following line at the top of your code to set the base to zero:
option base 0 |
|