Find last row and column for 1st page only

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...
 
G

geniusideas

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..
 
G

geniusideas

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..
 
G

geniusideas

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..
 
J

Jim

via Google I saw this link
http://www.mrexcel.com/archive/VBA/19134.html
Looks very clever, not sure I understand it but could be a starting point


Jim


"geniusideas" wrote in message

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top