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,
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
42,237
Office Version
365
Platform
Windows
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.
 

tschop

New Member
Joined
Dec 15, 2014
Messages
13
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
 

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
42,237
Office Version
365
Platform
Windows
Glad you got it sorted.
 

tschop

New Member
Joined
Dec 15, 2014
Messages
13
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
 

Forum statistics

Threads
1,081,992
Messages
5,362,601
Members
400,683
Latest member
LogChief

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top