Populating an VB array - from a range of cells

GerrySoccer

New Member
Joined
Aug 15, 2002
Messages
10
Hello All:

Let's say I have a range of cells (Excel 97) of say 30 columns and 25 rows. The data is a mixture of strings and numbers.

I want to put this data into an array. When I DIMed a 2-D array and tried to assign the VALUE of the range to the array, it didn't work.

Any help would be greatly appreciated.

Gerry
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Mudface

MrExcel MVP
Joined
Feb 18, 2002
Messages
3,339
Try this instead, it'll return a 2-D (1-based rather than 0-based) array of your values: -

Code:
Dim x As Variant

x = Range(Cells(1, 1), Cells(25, 30))

HTH.
 

Jay Petrulis

MrExcel MVP
Joined
Mar 17, 2002
Messages
2,040
Hi,

x = Range(your range).value

will give you a 2-D array, no matter what the dimensions of your range. Note that a one column range will be dimensioned x(rows,1)
 

Watch MrExcel Video

Forum statistics

Threads
1,130,169
Messages
5,640,547
Members
417,151
Latest member
ChickenTenderer

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
Top