Anyone know how to copy a Range of Cells into an Array?

GeorgeAdamson

New Member
Joined
Feb 24, 2002
Messages
14
Is there a command to do it or do I have to loop through the Range adding each cell value to the array one by one?

Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
It's fairly straightforward to assign the cells in a range to an array. It's also a very quick way of working with large amounts of worksheet data.

Sub GetArray()
Dim vArray()
vArray = Range("A1:E10")
'vArray now contain a 10 x 5 array of values
'You can work with it and then assign it back to a range - this is much quicker
'than populating cells one at a time through a loop e.g.

Range("F1:J10").Value = vArray

End Sub


HTH,
D
 
Upvote 0

Forum statistics

Threads
1,213,554
Messages
6,114,280
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top