如何VBA中设置动态分页打印

2025-05-11 04:48:02
推荐回答(1个)
回答1:

Sub 重新排版()
'
' 重新排版 宏
'
Dim xWkst As Worksheet
Dim y As Integer

For Each xWkst In ThisWorkbook.Sheets
xWkst.ResetAllPageBreaks
For y = 2 To Cells(2, 255).End(xlToLeft).Column
If Cells(2, y).Value = "结论" Then
xWkst.VPageBreaks.Add (xWkst.Cells(2, y + 1))
End If
Next y
Next xWkst

End Sub