VBS中的数组分配

时间:2017-09-15 12:50:42

标签: excel vbscript

我有一张Excel表格,其数据范围从A5到AU3950。我想将数据复制到一个维度为MyArray(3950, 68)的数组中。我想将每一行(A5:AU5)复制到MyArray(ArrayRow,28到67)。

Sub Import(ByRef MyArray, Sheet)
    Dim Colx, Rowx, ArrayRow, ArrayCol
    Dim Wsheet
    Dim TempArray()
    Set WSheet = MyWorkBook.Sheets(Sheet)
    WSheet.Activate
    LastRow = WSheet.Cells(WSheet.Rows.Count, "A").End(-4162).Row
    ReDim MyArray(LastRow-4, 68)
    ArrayRow = 0
    For Rowx = 5 To LastRow
        ArrayCol = 28
        TempArray = WSheet.Range(WSheet.Cells(Rowx, 7), WSheet.Cells(Rowx, 46)).Value
        MyArray(ArrayRow, ArrayCol) = TempArray
        ArrayRow = ArrayRow + 1
    Next
End Sub

0 个答案:

没有答案