ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Assigning range to array not working (https://www.excelbanter.com/excel-programming/306808-assigning-range-array-not-working.html)

Marston

Assigning range to array not working
 
Can someone explain why this isn't working?

Sub Test()
Dim aArray as Variant

Set rng = Range("A1").CurrentRegion.Select
aArray = rng.Value

End Sub

When I break the code I see the following when I highlight
aArray

(on the Set rng, I put arrow of rng and I see: rng = nothing)
(on the rng.Value, I see <Object variable or With block variable not set

I have values in a 51000 x 10 range beginning at "A1"

Alan Beban[_2_]

Assigning range to array not working
 
Marston wrote:
Can someone explain why this isn't working?

Sub Test()
Dim aArray as Variant

Set rng = Range("A1").CurrentRegion.Select
aArray = rng.Value

End Sub

When I break the code I see the following when I highlight
aArray

(on the Set rng, I put arrow of rng and I see: rng = nothing)
(on the rng.Value, I see <Object variable or With block variable not set

I have values in a 51000 x 10 range beginning at "A1"


Drop the .Select

Alan Beban

Marston

Assigning range to array not working
 
Thanks Alan -

and please disregard the next message too.....I think I'm back to where I was
yesterday - at least I'm able to write out my arrays now.


Alan Beban wrote in message ...
Marston wrote:
Can someone explain why this isn't working?

Sub Test()
Dim aArray as Variant

Set rng = Range("A1").CurrentRegion.Select
aArray = rng.Value

End Sub

When I break the code I see the following when I highlight
aArray

(on the Set rng, I put arrow of rng and I see: rng = nothing)
(on the rng.Value, I see <Object variable or With block variable not set

I have values in a 51000 x 10 range beginning at "A1"


Drop the .Select

Alan Beban



All times are GMT +1. The time now is 05:10 PM.

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