This is an awesomely simple problem, but I've been breaking my head against it for an hour. I'm trying to do the following:
- define a VBA array from a named range in my spreadsheet
- Access an item in that array
Now, if the named range happens to cover a multi-dimensional area (rows and columns), then this works fine:
foobar = Range("two_dimensional_range")
MsgBox foobar(1,1)
However, if the named range consists of a single dimension (just a column) of data, then this produces a "Subscript Out of Range" error:
foobar = Range("one_dimensional_range")
MsgBox foobar(1)
I've verified that foobar is really an array. I can iterate through it with For Each ... Next. If I call Ubound(foobar) then it gives me the correct size. I just can't access a single element of it directly!
What am I doing wrong?