ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Writing Range to Array (https://www.excelbanter.com/excel-programming/306438-writing-range-array.html)

Marston

Writing Range to Array
 
Can someone tell me what I'm not doing correctly?

Sub Test()
Dim aArray as Variant
Dim rng As Range
Range("A1").Select
Set rng = ActiveCell.CurrentRegion.Select
aArray.Value = rng.Value
End Sub

Frank Kabel

Writing Range to Array
 
Hi
try
Sub Test()
Dim aArray()
Dim rng As Range

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

--
Regards
Frank Kabel
Frankfurt, Germany


Marston wrote:
Can someone tell me what I'm not doing correctly?

Sub Test()
Dim aArray as Variant
Dim rng As Range
Range("A1").Select
Set rng = ActiveCell.CurrentRegion.Select
aArray.Value = rng.Value
End Sub


Alan Beban[_2_]

Writing Range to Array
 
Frank Kabel wrote:

Hi
try
Sub Test()
Dim aArray()
Dim rng As Range

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

That doesn't work either, at least not in xl2000. So either it wasn't
tested before posting or Frank Kabel is using a later version in which
it works. Use

aArray = rng.Value

or

Dim aArray As Variant
aArray = rng or aArray = rng.Value

Alan Beban

Frank Kabel

Writing Range to Array
 
Hi Alan
just a typo on my site. Forgot to remove the .value part

Thanks for the correction


--
Regards
Frank Kabel
Frankfurt, Germany


Alan Beban wrote:
Frank Kabel wrote:

Hi
try
Sub Test()
Dim aArray()
Dim rng As Range

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

That doesn't work either, at least not in xl2000. So either it wasn't
tested before posting or Frank Kabel is using a later version in

which
it works. Use

aArray = rng.Value

or

Dim aArray As Variant
aArray = rng or aArray = rng.Value

Alan Beban




All times are GMT +1. The time now is 11:45 PM.

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