Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Format page number in excel footer to start at a specific page # | Excel Discussion (Misc queries) | |||
change page number watermark in page break preview | Excel Discussion (Misc queries) | |||
change and/or remove page number watermark in page break preview | Excel Discussion (Misc queries) | |||
Hiding the page number in page break preview background. | Excel Discussion (Misc queries) | |||
sheet tabs as page number and in a cell page of pages? | Excel Discussion (Misc queries) |