- 帖子
- 471
- 主題
- 121
- 精華
- 0
- 積分
- 579
- 點名
- 0
- 作業系統
- WIN10
- 軟體版本
- OFFICE2019
- 閱讀權限
- 50
- 性別
- 男
- 註冊時間
- 2015-4-16
- 最後登錄
- 2023-1-17
|
回復 9# lpk187
不好意思..有點卡關 新的程式碼
會選擇所有列,另外用變數計算列後再放入會變只選取最上面兩列
Sub 巨集()
Dim c As Range, firstAddress$, myColumn%
With Sheets("工作表1")
Set c = .Rows(3).Find("P.P", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
myColumn = 1
Do
.Range(.Cells(2, myColumn), .Cells(Rows.Count, c.Column).End(xlUp)).Name = "Print_Area"
.PrintOut Copies:=1, Collate:=True, IgnorePrintAreas:=False
Set c = .Rows(3).FindNext(c)
myColumn = myColumn + 19
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
End Sub |
|