VBA pagebreak question!

Joined
Feb 29, 2012
Messages
2
Reaction score
0
I actually had a line of code that worked just fine Excel 2003 VBA, but am currently pulling my hair off as the line gives an error in 2010 VBA.


Basically, I want to be able to have the first several pages'(until the "PageNum"-th page) pagebreak to be specifically set. After that, I want the PageNum-th page to be all encompassing until the lastrow of the data.

I used to use the function ActiveSheet.HPageBreaks().Location which seems to play a different role in 2010.


For example I have,

ActiveSheet.HPageBreaks(PageNum).Location = Range("A" & LastRowNumber)


Could anyone kindly help me solve this issue please?

thanks!
 
to add on / clarify, I dont get a run-time "error message" per se, but just get the wrong finished product.

For example, if I have the line
ActiveSheet.HPageBreaks(PageNum).Location = Range("A" & LastRowNumber)
and say the integer variable PageNum was 9 in this case,

in Excel 2003, The 9th Pagebreak will be set right after the LastRowNumber-th row.
in Excel 2010, the CURRENT 9th pagebreak location (which is not always at the LastRowNumber-th row) is pulling in the value from Range("A" & LastRowNumber) , as if the line of code was

ActiveSheet.HPageBreaks(PageNum).Location.value = Range("A" & LastRowNumber) Range("A" & LastRowNumber) .value

I hope that makes more sense.
 
Back
Top