关于合并相同格式工作簿到同一空白工作簿的再讨论

Sub 合并相同格式的工作簿至同一工作簿()
    Dim i As Integer, arr()
    Dim dic As Object, wb As Object
    For j = 1 To 23 '只有23个班,故设为23
        Set wb = GetObject(ThisWorkbook.Path & "\" & Trim(Str(j)) & "班\" & "sy.xls")
        With wb.Sheets("sheet1")
            i = .Range("A65536").End(xlUp).Row
            arr = .Range("A2").Resize(i - 1, 12).Value '共12列,故设为12
        End With
        wb.Close False
        Debug.Print Trim(Str(j)) & "班人数:" & UBound(arr)
        With ThisWorkbook.Sheets("sheet1")
            i = .Range("A65536").End(xlUp).Row
            .Range("A1").Resize(i + UBound(arr), 12).NumberFormatLocal = "@"
            .Range(Cells(i + 1, 1), Cells(i + 1, 1)).Resize(UBound(arr), 12).Value = arr
            '上句意思为:从i+1行开始,resizeUbound(arr)行,这样正好与arr数组的范围相吻和.
        End With
        Erase arr
    Next j
End Sub

菊子曰 今天你 菊子曰了么?

你可能感兴趣的:(工作)