# split a large array into smaller array

##### Board Regular
I am trying to separate a 2D array of integers into multiple 1D array of integers. Does anyone know how to do that? I looked into the split, join functions, but they work with strings. I guess that I could convert my integers to strings, and put some sort of delimiter in it. The main reason I would like to do this is because of the worksheetfunction.sum(arg1). My individual arrays have to some up to something.

The only other option I can see is to use a dictionary or collection with the arrays as containers. That would probably work as well, but I just wanted to hear your thoughts on getting splitting up a 2D array into smaller array. I have been able to do this using pointers in C, but am not sure if it can be done in VBA.

### Excel Facts

If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
use a 1D array of 1D arrays

Code:
``````Sub test()

Dim my2DArray(1 To 5) As Variant

my2DArray(1) = Array(1, 2, 3, 4, 5)
my2DArray(2) = Array("abc", "xyz")
my2DArray(3) = Array(22, 33, "qwerty")
my2DArray(4) = Array(1, 2, 3)
my2DArray(5) = Array(9, 8, 7)

End Sub``````

Here's an example of how to load an existing 2D Array into a 1D array of 1D arrays.

Code:
``````Sub Example2DArrayTo1DArrayOf1DArrays()

Dim Input_Rng, Temp(), Output()

'load an example 2D Array A1:E3
Input_Rng = Range("A1").Resize(3, 5).Value

'split out rows
ReDim Output(1 To UBound(Input_Rng))

For i = 1 To UBound(Input_Rng)
ReDim Temp(1 To UBound(Input_Rng, 2))
For j = 1 To UBound(Input_Rng, 2)
Temp(j) = Input_Rng(i, j)
Next j
Output(i) = Temp
Next i

'show the format to identify one value
MsgBox Output(3)(2)
End Sub``````

I am trying to separate a 2D array of integers into multiple 1D array of integers. Does anyone know how to do that? I looked into the split, join functions, but they work with strings. I guess that I could convert my integers to strings, and put some sort of delimiter in it. The main reason I would like to do this is because of the worksheetfunction.sum(arg1). My individual arrays have to some up to something.
Which direction do you want to slice the 2D array... row-wise or column-wise?

Would it be okay to give you code that produced the sums you are looking for, or do you need the 1D array "slices" for some other purpose?

Hi

Can you give an idea of the dimensions of the array (rowsxcolumns)?

Replies
4
Views
437
Replies
0
Views
103
Replies
3
Views
152
Replies
5
Views
353
Replies
4
Views
169

1,196,329
Messages
6,014,681
Members
441,835
Latest member
rthomas268

### 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.

### Which adblocker are you using?

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

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