Getting Value of Array element in Immediate Window

  • Thread starter Thread starter Jim May
  • Start date Start date
J

Jim May

If I have the following code: (Only first three lines shown)

Sub namesheets()
Dim arr As Variant
arr = Range("A1:A3").Value

and I STEP -THROUGH IT (using F8 key)
after completing Line 3

I wish to go to my immediate Window
and view say

? arr(2).value <<< but this of course is not working Get R/T 9 -
subscript out of range..

what should I enter instead?
TIA,
 
It's 2D Jim and there is no Value property

?arr(2,1)


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
? arr(2,1).Value

an array produced this way is always one based and two dimensional.

In your case Arr(1 to 3, 1 to 1)
 
Put a watch on arr.

You'll see that it's array, but it's a 3x1 array (3 rows x 1 column).

So if you used:

?arr(2,1)

you'll see a result.

And your array isn't a range, so it doesn't have a .value property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top