ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting Value of Array element in Immediate Window (https://www.excelbanter.com/excel-programming/335636-getting-value-array-element-immediate-window.html)

Jim May

Getting Value of Array element in Immediate Window
 
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,



Bob Phillips[_6_]

Getting Value of Array element in Immediate Window
 
It's 2D Jim and there is no Value property

?arr(2,1)


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim May" wrote in message
news:YWKFe.1163$MZ6.59@lakeread01...
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,





Tom Ogilvy

Getting Value of Array element in Immediate Window
 
? 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)

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:YWKFe.1163$MZ6.59@lakeread01...
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,





Jim May

Getting Value of Array element in Immediate Window
 
Tks Bob
I should remember that in my reading
of all this :-)

"Bob Phillips" wrote in message
...
It's 2D Jim and there is no Value property

?arr(2,1)


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim May" wrote in message
news:YWKFe.1163$MZ6.59@lakeread01...
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,







Dave Peterson

Getting Value of Array element in Immediate Window
 
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.



Jim May wrote:

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,


--

Dave Peterson

Tom Ogilvy

Getting Value of Array element in Immediate Window
 
Sorry
? arr(2,1).Value

should be without the Value

? arr(2,1)

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
? 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)

--
Regards,
Tom Ogilvy

"Jim May" wrote in message
news:YWKFe.1163$MZ6.59@lakeread01...
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,








All times are GMT +1. The time now is 01:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com