Skip to Content

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    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
    
    Add comment
    10|10000 characters needed characters exceeded