Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Pagebreak()
- Dim cl As HPageBreak
- Dim ws As Worksheet
- Dim shp As Shape
- Dim rng As Range
- Dim flg As Boolean
- Dim loopCount As Integer: loopCount = 1
- Do While ActiveSheet.HPageBreaks.Count + 1 <> loopCount
- Set cl = ActiveSheet.HPageBreaks(loopCount)
- printColCount = ActiveSheet.Range(Sheets("Sheet1").PageSetup.PrintArea).Columns.Count
- Debug.Print ("改ページ=" & ActiveSheet.HPageBreaks.Count)
- '
- If Not ActiveSheet.Cells(cl.Location.Row, Cells(cl.Location.Row, printColCount).End(xlToLeft).Column).Value = "" Then
- ActiveSheet.Cells(cl.Location.Row, Cells(cl.Location.Row, printColCount).End(xlToLeft).Column).Select
- Do Until ActiveCell.Offset(-1, 0).Value = ""
- ActiveCell.Offset(-1, 0).Select
- Loop
- Dim iRow
- iRow = ActiveCell.Row
- Range("A" & iRow).Pagebreak = xlManual
- End If
- Set rng = ActiveSheet.Cells(cl.Location.Row, 5)
- '
- For Each shp In ActiveSheet.Shapes
- If Intersect(ActiveSheet.Range(shp.TopLeftCell, shp.BottomRightCell), rng) Is Nothing = False Then
- shp.TopLeftCell.Select
- Dim iRow2
- iRow2 = ActiveCell.Row
- Range("A" & iRow2).Pagebreak = xlManual
- End If
- Next
- loopCount = loopCount + 1
- Loop
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement