Changing from message box to insertion of text into cells

ardykav

Board Regular
Joined
Oct 18, 2015
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hi,

Thanks to PGC01 for the below code to show where page breaks are on a sheet. I was just looking to edit the code so that rather than the message box appearing it actually puts the text in the row itself. Something like "There is a page break on this row" in column A would do the trick I think.

Sub pagebreaklook()
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
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
How about

VBA Code:
Sub PageBreakText()
  Dim h As HPageBreak
  For Each h In ActiveSheet.HPageBreaks
    Range("A" & h.Location.Row).Value = "There is a page break on this row"
  Next
End Sub
 
Last edited:
Upvote 0
Absolutely perfect, thanks so much
How about

VBA Code:
Sub pagebreaklook()
  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
      Range("A" & hpbs(j).Location.Row).Value = "There is a page break on this row"
    Next j
  End If
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,693
Members
448,979
Latest member
DET4492

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