cancel
Showing results for 
Search instead for 
Did you mean: 

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

daniel_mccollum
Active Contributor
0 Kudos

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.

Cheers

Daniel

Accepted Solutions (1)

Accepted Solutions (1)

daniel_mccollum
Active Contributor

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

Answers (0)