locked
How do I find out if there is a page break in a fragment? RRS feed

  • Question

  • How can I find out programmatically whether or not there is a page break in A3:B3?
    How can I find out programmatically whether or not there is a page break in E3:F3?




    • Edited by MSDN Member Thursday, April 23, 2020 7:59 PM
    Thursday, April 23, 2020 7:54 PM

Answers

  • Hi,

    You can check if a Horizontal PageBreak is at A3 by this code.
    Sub PageBreak()
        Dim hPB As HPageBreak
        For Each hPB In ActiveSheet.HPageBreaks
            If (hPB.Location.Address = "$A$3") Then
                MsgBox "A3 has a horizontal PageBreak"
            Else
                MsgBox "A3 does NOT have a horizontal PageBreak"
            End If
        Next hPB
    End Sub
    Regards,

    Ashidacchi -- http://hokusosha.com

    • Marked as answer by MSDN Member Friday, April 24, 2020 3:49 AM
    Friday, April 24, 2020 2:32 AM

All replies

  • Hi,

    What do you mean by "a page break"?
    What is the answer of "a page break in A3:B3", "a page break in E3:F3"? 

    Regards,

    Ashidacchi -- http://hokusosha.com

    Friday, April 24, 2020 1:08 AM
  • Hi,

    You can check if a Horizontal PageBreak is at A3 by this code.
    Sub PageBreak()
        Dim hPB As HPageBreak
        For Each hPB In ActiveSheet.HPageBreaks
            If (hPB.Location.Address = "$A$3") Then
                MsgBox "A3 has a horizontal PageBreak"
            Else
                MsgBox "A3 does NOT have a horizontal PageBreak"
            End If
        Next hPB
    End Sub
    Regards,

    Ashidacchi -- http://hokusosha.com

    • Marked as answer by MSDN Member Friday, April 24, 2020 3:49 AM
    Friday, April 24, 2020 2:32 AM
  • Thanks. I thought Location would return an entire row. I didn't think to analyze the Location property.
    Friday, April 24, 2020 3:48 AM