本帖最後由 starry1314 於 2016-12-6 10:03 編輯
樞紐分析表
請問VBA該如何設定 自動選擇列印範圍後列印
1.分成三張 1F、2F、3F
2.目前想法是A2開始到下一列 並包含合計兩字的列 為列印範圍
3.在從上次運行結果的下一列重複循環..
自動循環列印_判斷列印範圍.rar (10.68 KB)
此為橫向的方式- Option Explicit
- 'LPK87 提供
- Sub 巨集1()
- Dim c As Range
- With Sheets("工作表1")
- Set c = .Rows(3).Find("P.P", , , , , 1) '往後尋找
- .PageSetup.PrintArea = .Range(.Cells(Rows.Count, 1).End(xlUp), Cells(2, c.Column)).Address '設定列印範圍
- .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '列印
- Set c = Nothing
- Set c = .Rows(3).Find("P.P", , , , , 2) '往前尋找
- .PageSetup.PrintArea = .Range(.Cells(Rows.Count, 1).End(xlUp), Cells(2, c.Column)).Address '設定列印範圍
- .PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False '列印
- Set c = Nothing
- End With
- End Sub
複製代碼 |