Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I write the code to return a page number within a given worksheet, so
that that number can be used (1) in an expression or (2) to cut, paste, delete, etc the page? Also, the code to return the number of pages in a worksheet? Thanks very, very much for any assistance. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi JCIrish
You can do this but it is not fast This will give you the pages pgnum = ExecuteExcel4Macro("Get.Document(50)") This will copy the pages to another sheet http://www.rondebruin.nl/hpagebreaks.htm This give you the activecell page Sub CurrentPage() Dim VPC As Integer, HPC As Integer Dim VPB As VPageBreak, HPB As HPageBreak Dim NumPage As Integer If ActiveSheet.PageSetup.Order = xlDownThenOver Then HPC = ActiveSheet.HPageBreaks.Count + 1 VPC = 1 Else VPC = ActiveSheet.VPageBreaks.Count + 1 HPC = 1 End If NumPage = 1 For Each VPB In ActiveSheet.VPageBreaks If VPB.Location.Column ActiveCell.Column Then Exit For NumPage = NumPage + HPC Next VPB For Each HPB In ActiveSheet.HPageBreaks If HPB.Location.Row ActiveCell.Row Then Exit For NumPage = NumPage + VPC Next HPB MsgBox "Page number of the active cell = " & NumPage ' ActiveWindow.SelectedSheets.PrintOut _ ' From:=NumPage, To:=NumPage, _ ' Copies:=1, Collate:=True End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "JCIrish" wrote in message ... How do I write the code to return a page number within a given worksheet, so that that number can be used (1) in an expression or (2) to cut, paste, delete, etc the page? Also, the code to return the number of pages in a worksheet? Thanks very, very much for any assistance. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Unique Footer for each page in worksheet with a page number | Excel Worksheet Functions | |||
Excel 2002 : How to reduce the number of unused worksheet ? | Excel Discussion (Misc queries) | |||
How to return the Number of shares for a given stock code for a given portfolio | Excel Discussion (Misc queries) | |||
Is there a function that will return the page number? | Excel Worksheet Functions | |||
Return to previous worksheet after code pastes in another worksheet? | Excel Programming |