Excel 陣列值,一次直接寫入儲存格

Function temp234()

Dim arr(1 To 10) As Integer

    For i = 1 To 10

        arr(i) = i

    Next i

    '橫向寫入

    Sheets("test").Range("a1:j1") = arr

    '直向寫入

    Sheets("test").Range("a1:a10") = Application.WorksheetFunction.Transpose(arr)

End Function

留言