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

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
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.
 
Upvote 0
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)
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

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