vba - Preventing Excel page break in middle of named range -


i'm looking format report printing using vba , can't find reliably stop last portion of report (under line-by-line data) getting split when doing print setup: last portion named-range called totalsrange i'm fitting printable area 1 page wide.

if report data between 23 , 34 rows long, page break occurs in middle of last range. can circumvent using following (forcing page break before named range):

if range("totalsrange")(1, 1).row > 23 , range("totalsrange")(1, 1).row < 34     activesheet.hpagebreaks.add before:=range("totalsrange")(1, 1) end if 

however, if report longer, same occur. in principle modulo of range("totalsrange")(1, 1).row (to base) being under threshold, require lot of trial , error work, since have account header section being carried on onto each page (meaning wouldn't mod 23).

is there neater way force excel not page-break within named range when autofitting 1 page wide? googling has revealed nothing.

many thanks!


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -