no page break in named range

C

Chris Salcedo

I have a sheet that has about 110 named ranges in it. They are about
15 rows tall (they can vary). What I would like to do is when I go to
print (11x17) a named range will not get cut off (i.e. part on one
page and part on the next page) Like a keep together. A macro that
would insert the page breaks on the sheet would work great.
 
J

Joel

Sub AddBreaks()

With ActiveSheet
For Each NamedRange In Names
'remove the equal sign
addr = Mid(NamedRange.RefersTo, 2)
StartRow = Range(addr).Row
NumRows = Range(addr).Rows.Count
EndRow = StartRow + NumRows - 1
.HPageBreaks.Add Before:=Range("A" & (EndRow + 1))
Next NamedRange
End With
End Sub
 
C

Chris Salcedo

Sub AddBreaks()

With ActiveSheet
   For Each NamedRange In Names
      'remove the equal sign
      addr = Mid(NamedRange.RefersTo, 2)
      StartRow = Range(addr).Row
      NumRows = Range(addr).Rows.Count
      EndRow = StartRow + NumRows - 1
      .HPageBreaks.Add Before:=Range("A" & (EndRow + 1))
   Next NamedRange
End With
End Sub

This works but not exactly what I need..

Each range can be variable and I would like to have more than one
range per sheet. just not split a range if its in the middle...

Some thing like: if range fits page no page break if not then page
break at previous end named range...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top