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

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
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.
 
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,167,991
Messages
5,856,683
Members
431,828
Latest member
kARTIK12345

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