Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Display current page number in a cell on Excel

85 views
Skip to first unread message

Matt

unread,
Mar 5, 2000, 3:00:00 AM3/5/00
to
Does any one know how to display page numbers in excel without using the
header function. I.e, to display the following in ordinary cells

Page ?? of ??

Please help....

Thanks
Matt

--
Posted via CNET Help.com
http://www.help.com/

Laurent Longre

unread,
Mar 5, 2000, 3:00:00 AM3/5/00
to
Matt wrote:
>
> Does any one know how to display page numbers in excel without using the
> header function. I.e, to display the following in ordinary cells
>
> Page ?? of ??

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
ActiveCell = "Page " & NumPage & " of " & _
Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")

Cordialement,

Laurent

0 new messages