- 帖子
- 254
- 主題
- 6
- 精華
- 0
- 積分
- 310
- 點名
- 0
- 作業系統
- W10
- 軟體版本
- Excel 2016
- 閱讀權限
- 20
- 性別
- 男
- 來自
- 台灣
- 註冊時間
- 2019-6-16
- 最後登錄
- 2025-6-21
|
以下是試著練習的結果 程式很攏長 請大大們指點一下看看有沒有地方不適合這樣的寫法
請告知小弟 請問如果要設定列印分頁的頁數範圍 該如何寫呢? 請大大們幫幫忙- Sub 測試練習()
- Application.ScreenUpdating = False
- Dim A()
- For I = 2 To Sheets.Count
- ReDim Preserve A(I - 1)
- A(I - 1) = Sheets(I).Cells(2, 2)
- Next I
-
- G = Application.Max(A)
- ActiveWorkbook.Save
- For k = 1 To G
- For I = 2 To Sheets.Count
- Sheets(I).Select
- If Format(Sheets(I).Cells(2, 2), "[DBNum1]0") = Format(k, "[DBNum1]0") Then
- If Sheets(1).Cells(6, 2) = "" Then
- Sheets(I).Range(Cells(1, 1).SpecialCells(xlCellTypeConstants), Sheets(I).Cells(1, 1).SpecialCells(xlCellTypeLastCell)).Copy Sheets(1).Cells(6, 2)
- ElseIf Sheets(1).Cells(6, 2) <> "" Then
- u = Sheets(1).Cells(1, 1).SpecialCells(xlCellTypeLastCell).Offset(2, 0).Address(0, 0)
- Sheets(I).Range(Cells(1, 1).SpecialCells(xlCellTypeConstants), Sheets(I).Cells(1, 1).SpecialCells(xlCellTypeLastCell)).Copy Sheets(1).Cells(Mid(u, 2), 2)
- End If
- End If
- Next I
- Next k
- Sheets(1).Select
- Range(Cells(1, 1), Cells(1, 1).SpecialCells(xlCellTypeLastCell).Offset(0, 1).Address(0, 0)).Name = "Print_Area"
-
- Application.ScreenUpdating = True
- End Sub
複製代碼 |
|