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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

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)
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,649
Messages
5,832,879
Members
430,175
Latest member
Sheenamarie

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