Return array of page ranges

  • Thread starter Thread starter XP
  • Start date Start date
X

XP

Using Windows XP and Office 2003.

Hi, I need a function that will retrieve the range address of each defined
page range on a sheet.

For example, if page one is set to A2:H50, and page two is set to A51:H80, I
need to retrieve each of these sets of ranges. The number of pages may vary
at different times. I would prefer to work with an array if possible.

Your assistance in the form of example code would be greatly appreciated.
 
Page ranges??? Do you mean print ranges or named ranges or ???
 
Sorry, yes, a defined print range that may include one to any number of
pages arranged vertically on the sheet.

If you switch the sheet to page break preview you can see where the page
range is defined and where the breaks will occur outline in a solid blue line.

I need an array of each of those page ranges...e.g. A2:H43, A44:H87, etc.

Thanks...
 
Here is the location of the page breaks... I see that the print area you have
is A2 to ??? Is it a defined print area or is it just everything on the sheet?

Dim lngPageBreaks() As Long
Dim lng As Long
Dim hpb As HPageBreak
Dim wks As Worksheet

Set wks = ActiveSheet

For Each hpb In wks.HPageBreaks
ReDim Preserve lngPageBreaks(lng)
lngPageBreaks(lng) = hpb.Location
lng = lng + 1
Next hpb

For lng = LBound(lngPageBreaks) To UBound(lngPageBreaks)
MsgBox lngPageBreaks(lng)
Next lng
 

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

Back
Top