How to load an array?

jshirts

New Member
Joined
Aug 19, 2002
Messages
9
How do you load a 1D array using a 2D array in one line of code?

I tried the following:

Dim a1(5,10) as Variant
Dim a2(10) as Variant

...load a1 with values...

For x=0 to UBound(a1,2)-1
a2=a1(x)()
Next x

But it didn't work, and I would like to avoid loading a2 one element at a time. Any ideas?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi shirts,

You didn't mention which row of a1 you want to load into a2. Here's what is should be if you want to load row 1:

For x=0 to UBound(a1,2)-1
a2(x)=a1(1,x)
Next x

Damon
 
Upvote 0

Forum statistics

Threads
1,224,895
Messages
6,181,620
Members
453,057
Latest member
LE102024

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