|
本帖最后由 chenbiao2012 于 2015-1-30 23:28 编辑
- Sub test()
- Application.DisplayAlerts = False
- Application.ScreenUpdating = False
- crr = Array(Array(1, 2, 3, 4, 25, 26, 27, 28, 29, 30, 31), Array(1, 2, 3, 4, 33), Array(1, 2, 3, 4, 46))
- mypath = ThisWorkbook.Path & ""
- myname = Dir(mypath & "*.xls")
- Do While myname <> "" And myname <> ThisWorkbook.Name
- Set wb = GetObject(mypath & myname)
- arr = wb.Sheets("sheet1").UsedRange
- For k = 0 To 2
- ReDim brr(1 To UBound(arr), 1 To UBound(crr(k)) + 1)
- For i = 1 To UBound(arr)
- For j = 1 To UBound(crr(k)) + 1
- brr(i, j) = arr(i, crr(k)(j - 1))
- Next
- Next
- Set wk = Workbooks.Add
- With wk
- .Sheets("sheet1").[a1].Resize(UBound(brr), UBound(brr, 2)) = brr
- .SaveAs mypath & k + 1 & "" & k & myname
- .Close False
- End With
- Next
- wb.Close False
- myname = Dir
- Set wb = Nothing
- Loop
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|