HPageBreaks.Add

tschop

New Member
Joined
Dec 15, 2014
Messages
13
I am trying to manipulate the horizontal page breaks in an Excel 2007 spreadsheet through VBA. The line of code I am using is:

For a = 1 To sheetcount - 1
ThisWorkbook.Worksheets("Continuation Sheet " & Trim(Str(k + 1))).Range(sheetrange).rows(a * 44).EntireRow.PageBreak = xlPageBreakManual
Next a

The code executes without error but does not move the horizontal page breaks. Any idea what I am doing wrong?

Thanks,
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
The code .. does not move the horizontal page breaks.
What page breaks should it be moving? You are not asking it to move any page breaks, just insert one every 44 rows.
 
Upvote 0
Peter,

Thanks for the reply. I realized that yesterday after posting. I have now cleared all the existing breaks and then set new ones and it seems to work perfectly. Thanks for you quick response and help.

Tom
 
Upvote 0
The code that sort of works is:

For a = 1 To sheetcount - 1
Set ThisWorkbook.Worksheets("Continuation Sheet " & Trim(Str(k + 1))).HPageBreaks(a).Location = Range("A" & (a * 44))
Next a

Ideally, I want to put a break after every 44 rows. The above line of code seems to only put the code before the specified range. is there a way to make it add the break after the specified range?

Thanks,

Tom
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,187
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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