|
由於打簡體不方便, 在你檔案中加入一頁Setting
- Sub zz()
- Dim a, b, c, wb As Workbook, ar, n%, t As Boolean, r&, rr&, s$, ss$
- Application.ScreenUpdating = 0
- Set wb = ThisWorkbook
- With Sheets("setting")
- a = .[a1].Value
- b = .Range("b1:b" & .[b65536].End(3).Row).Value
- c = .Range("c1:c" & .[c65536].End(3).Row).Value
- End With
- bb = Array(3, 4, 4, 4)
- For i = 1 To 3
- s = wb.Sheets(b(1, 1)).Cells(2, 2 + i).Value
- wb.Sheets(a).Copy
- Cells(3, 1).Value = Cells(3, 1).Value & s
- With ActiveWorkbook
- For j = 1 To UBound(c)
- t = IIf(j Mod 2, True, False)
- If t Then r = 7 Else r = 8
- rr = wb.Sheets(b(j, 1)).Cells(65536, bb(j - 1) + n).End(3).Row
- ar = wb.Sheets(b(j, 1)).Cells(bb(j - 1), bb(j - 1) + n).Resize(rr)
- wb.Sheets(c(j, 1)).Copy After:=.Sheets(.Sheets.Count)
- Cells(r, "e").Resize(rr - bb(j - 1) + 1).NumberFormat = 0
- Cells(r, "e").Resize(rr - bb(j - 1) + 1) = ar
- Next
- n = n + 1
- .Sheets(1).Activate
- .SaveAs s
- .Close
- ss = ss & Chr(10) & s
- End With
- Next
- Set wb = Nothing
- Application.ScreenUpdating = 1
- MsgBox n & " files saved as : " & ss
- End Sub
复制代码 |
|