VBA Write2dArrayToSheet

A subroutine to write the data of a 2D-string array to a worksheet.

Sub Write2dArrayToSheet(data() As String, ByRef sheet As Worksheet)
    Dim i, j, n, m As Long
    
    n = 1
    For i = LBound(data, 1) To UBound(data, 1)
        m = 1
        For j = LBound(data, 2) To UBound(data, 2)
            sheet.Cells(n, m) = data(i, j)
            m = m + 1
        Next j
        n = n + 1
    Next i
End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *