Return value in cell if there is a page break above

ExcelDane

Board Regular
Joined
May 14, 2009
Messages
82
Hi everybody

I need to be able to locate page breaks in a sheet automatically by returning a value in a cell if there is a page break above.
E.g. if there is a page break between row 3 and 4, I need cell A4 to return a value like "Page break".

I take it there must be a smart way to do this, maybe with a custom vba function. However, I haven't been able to google my way to a solution.

Thanks in advance!
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Try this:

Code:
Function PB(Cell As Range) As String
    Dim HPB As HPageBreak
    PB = ""
    For Each HPB In Cell.Parent.HPageBreaks
        If Not Application.Intersect(Cell, HPB.Location.EntireRow) Is Nothing Then
            PB = "Page Break"
            Exit For
        End If
    Next HPB
End Function

Usage =PB(A1).
 
Upvote 0

Forum statistics

Threads
1,195,588
Messages
6,010,606
Members
441,558
Latest member
lambierules

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top