Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Range use on page

Is there a way to determine the range of cells on a page using VBA?

I'm defining a page as the cells within a series of page breaks, automatic
or manual. So if it worksheet contains items in the first 3 rows and 5
columns, then usedrange property would return the first 3 rows and 5 columns.
However after a print preview Excel displays page breaks after column I and
after row 52. How can I determine this range through VBA, since these page
breaks do not appear through HPagebreaks or VPagebreaks.
--
Eric Howard
Director of Process Automation
Synergis Technologies, Inc.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Range use on page

Hi,
If i understand correctly, in the above example, you are trying to determine
the range A1:I52. That is, you need to detrmine the next 'potential' page
break.
I don't know of any direct way.
A messy and non-elegant way would be:
- Say there is 10 vertiocal page break
- Fill up row 1 with dummy data from the cell after the rightmost column of
the usedrange TO the last cell on that row on the sheet (IV1).
- Locate the new break (v page break 11)
- remove the dummy data
- do something similar to figure out the h page break

in vba, for v page break:
Sub test()
Dim wsh As Worksheet
Dim extRg As Range 'extended range = end of used range to end of
sheet
Dim currVBreaks As Long 'current number of vbreaks
Dim extVBreakCol As Long 'new extended vbreak's column

Set wsh = ActiveSheet
With wsh
currVBreaks = .VPageBreaks.Count
Set extRg =
..UsedRange.Cells.SpecialCells(xlCellTypeLastCell) .Offset(0, 1)
Set extRg = .Range(extRg, .Cells(1, 256)).Rows(1)
extRg.Formula = "="""""
extVBreakCol = .VPageBreaks(currVBreaks + 1).Location.Column
extRg.Formula = ""
End With

MsgBox extVBreakCol
End Sub

From there, you can determine the ranges.
Not very pretty since adding and removing dummy data 'modifies' the sheet,
but well... I hope this helps,
Sebastien

"Eric Howard" wrote:

Is there a way to determine the range of cells on a page using VBA?

I'm defining a page as the cells within a series of page breaks, automatic
or manual. So if it worksheet contains items in the first 3 rows and 5
columns, then usedrange property would return the first 3 rows and 5 columns.
However after a print preview Excel displays page breaks after column I and
after row 52. How can I determine this range through VBA, since these page
breaks do not appear through HPagebreaks or VPagebreaks.
--
Eric Howard
Director of Process Automation
Synergis Technologies, Inc.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for numbers in page range [email protected] Excel Worksheet Functions 4 February 2nd 07 11:58 PM
Printing Range at the beginning of every new page. Slick Willie Excel Programming 1 November 3rd 04 12:15 AM
Refer to Range Name in Page Header Al Excel Programming 2 October 6th 04 06:00 PM
Selecting all contents on page (range) andycharger[_19_] Excel Programming 1 April 5th 04 09:55 AM
How to Programmatically Insert a Page Break Every Nth Row in a Range KK[_3_] Excel Programming 0 November 21st 03 12:49 AM


All times are GMT +1. The time now is 06:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"