Playing with arrays... sort of

bdl004

New Member
Joined
Jul 16, 2010
Messages
12
Hi Guys,

I have a bit of a strange question...

What I have is an array such as the following: myArray(1)=(1 2 3 4 5), myArray(2)=(6 7 8 9 10), myArray(3)=(11 12 13 14 15), and myArray(4)=(16 17 18 19 20).


What I would like to do is to change this array such that I end up with: newArray(1)=1, newArray(2)=2, newArray(3)=3, etc. until myArray(20)=20.

I have tried using "split" to no avail thusfar and I am wondering if it is possible to do this?

Thanks very much in advance!
Brett
<!-- / message -->
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Example:

Code:
Sub Test()
    Dim myArray(1 To 4)
    Dim newArray As Variant
    myArray(1) = "1 2 3 4 5": myArray(2) = "6 7 8 9 10": myArray(3) = "11 12 13 14 15": myArray(4) = "16 17 18 19 20"
    newArray = Split(Join(myArray, " "), " ")
    MsgBox UBound(newArray)
End Sub

The variant array will be zero based.
 
Upvote 0

Forum statistics

Threads
1,214,412
Messages
6,119,365
Members
448,888
Latest member
Arle8907

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