#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Page Number

The Page break preview mode shows the area occupied by each page in an excel
worksheet. How can I programmatically know the page number for a given cell?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 135
Default Page Number

Hi Jess,

You can use this function of Laurent Longre
to find to which page number belongs a cell
of a worksheet

Copy this function in a general module

'-------------------------------------------
Sub test()
MsgBox NumeroPage(Range("G25"))
End Sub
'-------------------------------------------

'--------------------------------------------
Function NumeroPage(Cellule As Range) As Integer

Dim VPC As Integer, HPC As Integer
Dim VPB As VPageBreak, HPB As HPageBreak
Dim Wksht As Worksheet
Dim Col As Integer, Ligne As Long

Set Wksht = Cellule.Worksheet
Ligne = Cellule.Row
Col = Cellule.Column
If Wksht.PageSetup.Order = xlDownThenOver Then
HPC = Wksht.HPageBreaks.Count + 1
VPC = 1
Else
VPC = Wksht.VPageBreaks.Count + 1
HPC = 1
End If
NumeroPage = 1
For Each VPB In Wksht.VPageBreaks
If VPB.Location.Column Col Then Exit For
NumeroPage = NumeroPage + HPC
Next VPB
For Each HPB In Wksht.HPageBreaks
If HPB.Location.Row Ligne Then Exit For
NumeroPage = NumeroPage + VPC
Next HPB

End Function
'---------------------------------------------


"Jess" a écrit dans le message de groupe de discussion :
...
The Page break preview mode shows the area occupied by each page in an excel
worksheet. How can I programmatically know the page number for a given cell?

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
Format page number in excel footer to start at a specific page # straitctrydncr Excel Discussion (Misc queries) 4 April 28th 23 07:45 PM
change page number watermark in page break preview juga Excel Discussion (Misc queries) 2 December 25th 06 10:16 AM
change and/or remove page number watermark in page break preview juga Excel Discussion (Misc queries) 2 December 25th 06 10:15 AM
Hiding the page number in page break preview background. I need coffee, wake me up! Excel Discussion (Misc queries) 0 May 15th 06 10:32 AM
sheet tabs as page number and in a cell page of pages? [email protected] Excel Discussion (Misc queries) 0 November 22nd 05 02:43 PM


All times are GMT +1. The time now is 08:14 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"