Formula to return row number of page breaks

ardykav

Board Regular
Joined
Oct 18, 2015
Messages
172
Office Version
  1. 365
Platform
  1. Windows
I am looking to implement some headers on the basis of where page breaks are positioned on a sheet.

Is there a formula or VBA to return row values of where page breaks are located?

thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi

Try:

VBA Code:
Sub Test()
Dim hpbs As HPageBreaks
Dim j As Long

Set hpbs = ActiveSheet.HPageBreaks
If hpbs.Count = 0 Then
    MsgBox "No horizontal page breaks in active sheet"
Else
    For j = 1 To hpbs.Count
        MsgBox "Horizontal page break " & j & " at row: " & hpbs(j).Location.Row
    Next j
End If
End Sub
 
Upvote 0
That is great thanks so much, is there a way to put the message in the row that it is in? Or even just words like "there is a page break on this row"?
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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
Back
Top