Insert Page Break automatically??

jray

New Member
Joined
Mar 13, 2008
Messages
46
I generate a report with header information on each page. When I export it to to Excel it paginates differently from within the software.

On each page in column A is the word BUILDING. Is there a way to insert a page break above each occurence of the word BUILDING?

Thank you very much!!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Jray,

The following looks for the word in column A and then sets pagebreaks.

Change the range of for I = 10000 to meet your criteria as it will only search 10000 lines.

Code:
option compare text
Sub pagebreak1()
Application.ScreenUpdating = False
ActiveSheet.ResetAllPageBreaks
Dim rng1 As Range
    For I = 10000 To 1 Step -1
        Set rng1 = Range("A" & I)
        
        Select Case rng1.Value
            Case "BUILDING"
                'select row
                
                rng1.EntireRow.Select
                ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell
                
        End Select
    Next I
    Range("a1").Select
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thank you SOOOO much for the speedy reply.

It took me a while to actually reopen my computer. On first run it looks like you solved my problem!!

Thanks again!!!


Jim
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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