I am copying various ranges to a new Excel sheet, and looking for a solution to referencing the next page, or any specific page, while in Page Layout view.
I have already setup the page layout with margins, headers, and other formatting, and want to fill in my report based on the layout presented on screen. Since the layout is set, I can hard code the cell references to place my ranges, but I would rather determine this dynamically. Any solutions out there?
This is a tough one, but one suggestion could be that if you already have the layout set, then consider it your template page. There is a trick you can use to figure out if you'll "fall out of range," so-to-say. Before copying a new range to the template sheet, determine the height of the content you're copying and hold it against the "left-over" height of the destination (where the page will break). If it falls out of range, move it to the next page so you don't break up your ranges by the pages.
How would you know if it falls out of range? You can figure out a standard height per page when you start your code. Then decrement it as you paste on. This way will take care of different row heights you may have when copying/pasting.
To figure out the height, when you select the range in code, just check it's Height property (Range("A1").Height) and it will let you know where the next range's Top property will lay. Also, you could hard code the standard height (just highlight the cells that fit on one page and go to the immediate window and type ?Selection.Height and you'll have your standard height to work with).
Hope this helps!