There may be a better way, but here's a macro :-
Sub PageNumber()
Dim hpb As HPageBreak, p%, x%
For Each hpb In ActiveSheet.HPageBreaks
p = p + 1
If ActiveCell.Row< hpb.Location.Row Then
x = 1
MsgBox "The active cell is on page " & p
Exit For
End If
Next hpb
If x = 0 Then MsgBox "The active cell is on page " & p + 1
End Sub
And here's a function :-
Function PageNo(r As Range)
Dim hpb As HPageBreak, p%, x%
For Each hpb In ActiveSheet.HPageBreaks
p = p + 1
If r.Row< hpb.Location.Row Then
x = 1
PageNo = r.Address(False, False) & " is on page " & p
Exit For
End If
Next hpb
If x = 0 Then PageNo = r.Address(False, False) & " is on page " & p + 1
End Function
NOTE :
The above code assumes that there are no data that extend past the first vertical page break.
If this is not the case, the code needs to be re-written.
This message was edited by Pear on 2002-11-12 05:23