I want to find, with vba, which row a page break occurs. I am formatting some worksheets and each one will have a different number of rows on the first page due to the fact that I'm autofitting rows. For example, in one sheet, the first page may end at line 40, while on a different sheet it may end on 36 due to text wrapping and autofit. I simply need help storing the row number into a variable and I can take it from there.
This should get you thereVB:Sub GetPageBreaksRows() Dim hPB As HPageBreak Dim lRow As Long If ActiveSheet.HPageBreaks.Count > 0 Then For Each hPB In ActiveSheet.HPageBreaks lRow = hPB.Location.Row MsgBox lRow Next hPB End If End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)