Skip to Content

Excel VBA 2d Array copy segment to temp array, i.e. rows, 1 to 1000, then 1001 to 2000

Nov 10, 2017 at 02:58 AM


avatar image

Hi all,

Im looking for a clean way in VBA to take a 2d array & for segments of size foo, perform an action.

having trouble identifying a simple from X to Y condition I can loop over in order to have the master array split up for the follow up activities.

suggestions welcome.



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Daniel McCollum Nov 10, 2017 at 09:31 AM

I ended up just writing a function of my own to loop over the requisite ranges from Arr1 to Arr2 based on some inputs.

    'Loop through each empty element of Arr2 and set its value
    For j = 1 To UBound(Arr2, 2) 'Loop on columns
        refCol = columnIndex(j) 'Get column index
        For i = 1 To UBound(Arr2, 1) 'Loop on row
            Arr2(i, k) = arr1(i + rowStart - 1, refCol) 'move vals
        Next i
    Next j
10 |10000 characters needed characters left characters exceeded