Skip to content

Instantly share code, notes, and snippets.

@alezhu
Created November 30, 2016 06:43
Show Gist options
  • Save alezhu/a3ef85c0be7bc817cac5c004c8a9533f to your computer and use it in GitHub Desktop.
Save alezhu/a3ef85c0be7bc817cac5c004c8a9533f to your computer and use it in GitHub Desktop.
Page number for cell
Function GetCellPage(ra As range) As Long
Dim ws As Worksheet
GetCellPage = 0
Set ws = ra.Parent
Dim iRow As Long
If ws.HPageBreaks.Count > 0 Then
iRow = ra.Row
Do
GetCellPage = GetCellPage + 1
If GetCellPage > ws.HPageBreaks.Count Then
Exit Do
End If
Loop While ws.HPageBreaks.Item(GetCellPage).Location.Row <= iRow
End If
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment