Find last row and column for 1st page only

  • Thread starter Thread starter geniusideas
  • Start date Start date
G

geniusideas

Hi,

I need urgently to find last row and last column for 1st page in
printing using VBA. In my case when I print this worksheet it consist
multiple pages. The problem now I need to know for page one (1st page)
what is the last row and also column.
Could someone here can help.
Please...
 
Dear Sir,

I just want to know how many rows and columns in 1st page of printing?
That it..
How to count rows and column in HpageBreaks or VPageBreaks for page 1
only..
Thanks anyway..
 
Thank you guys.. Finally I found the answer as below..

Sub FndFirstPageRowAndColumn()
Dim Col As Integer
Dim LstCol As Integer
Dim LstColPg
Dim LstRowPg
LstColPg = ActiveSheet.VPageBreaks(1).Location.Column - 1
LstRowPg = ActiveSheet.HPageBreaks(1).Location.Row - 1
MsgBox "Column" & "= " & LstColPg & Chr(10) & "Row" & "= " & LstRowPg
End Sub

Thanks anyway..
 
Thanks Guys..

I Found the answer as below..
Sub FndFirstPageRowAndColumn()
Dim iHBreaks As Integer, iVBreaks As Integer
Dim LstColPg
Dim LstRowPg
iHBreaks = ActiveSheet.HPageBreaks.Count + 1
iVBreaks = ActiveSheet.VPageBreaks.Count
If iVBreaks > 1 Then
LstColPg = ActiveSheet.VPageBreaks(1).Location.Column - 1
Else
LstColPg = ActiveCell.SpecialCells(xlCellTypeLastCell).Column
End If
If iHpBreaks > 1 Then
LstRowPg = ActiveSheet.HPageBreaks(1).Location.Row - 1
Else
LstRowPg = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
End If
MsgBox "Column" & "= " & LstColPg & Chr(10) & "Row" & "= " & LstRowPg
End Sub

Thanks anyways..
 
Back
Top