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

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
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,218,594
Messages
6,143,383
Members
450,484
Latest member
ChrisMac1

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