Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 3
Default How to determine Last row of a Page in Excel

Hi,

I want to add Page border (for four sides) around each page in the spreadsheet of excel. My excel is having multipages in one spreadsheet and it is having nearly 6 spreadsheets. I have used PageBreaks to determine last row of a page but the pagebreak is 0 if i have only one page in a spreadsheet. So i want to know how to determine the last row of a page.

Thanks in Advance.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 160
Default How to determine Last row of a Page in Excel


LastRow = ActiveSheet.UsedRange.Row + ActiveSheet.UsedRange.Rows.Count

CE


Den 21.08.2013 12:20, divya nila skrev:

Hi,

I want to add Page border (for four sides) around each page in the
spreadsheet of excel. My excel is having multipages in one spreadsheet
and it is having nearly 6 spreadsheets. I have used PageBreaks to
determine last row of a page but the pagebreak is 0 if i have only one
page in a spreadsheet. So i want to know how to determine the last row
of a page.

Thanks in Advance.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default How to determine Last row of a Page in Excel

Hi,

I want to add Page border (for four sides) around each page in the
spreadsheet of excel. My excel is having multipages in one spreadsheet
and it is having nearly 6 spreadsheets. I have used PageBreaks to
determine last row of a page but the pagebreak is 0 if i have only one
page in a spreadsheet. So i want to know how to determine the last row
of a page.

Thanks in Advance.


This will vary dependant on several factors like RowHeight,
PageMargins, and FontSize, for instance. Best way to determine the last
printed page row is to do PrintPreview and observe the dotted page
outline[s], then set your borders to fit.

If you note a consistent number of rows for a printed page then you can
use that in VBA to set PageBreaks...

--
Garry

Free uenet access at http://www.eternal-september.org
Classic VB Users Regroup
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default How to determine Last row of a Page in Excel

hi,

MsgBox Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

isabelle

Le 2013-08-21 06:20, divya nila a écrit :

Hi,

I want to add Page border (for four sides) around each page in the
spreadsheet of excel. My excel is having multipages in one spreadsheet
and it is having nearly 6 spreadsheets. I have used PageBreaks to
determine last row of a page but the pagebreak is 0 if i have only one
page in a spreadsheet. So i want to know how to determine the last row
of a page.

Thanks in Advance.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default How to determine Last row of a Page in Excel

it same goes (nearly) for the last column

Sub test_Last()
'LastRow
LastRow = Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

'LastColumn
LastColumn = Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

Application.Goto Range(Cells(1, 1), Cells(LastRow, LastColumn))
End Sub

isabelle

Le 2013-08-21 11:31, isabelle a écrit :
hi,

MsgBox Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

isabelle

Le 2013-08-21 06:20, divya nila a écrit :

Hi,

I want to add Page border (for four sides) around each page in the
spreadsheet of excel. My excel is having multipages in one spreadsheet
and it is having nearly 6 spreadsheets. I have used PageBreaks to
determine last row of a page but the pagebreak is 0 if i have only one
page in a spreadsheet. So i want to know how to determine the last row
of a page.

Thanks in Advance.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default How to determine Last row of a Page in Excel

Hi Isabelle,

Am Wed, 21 Aug 2013 11:52:56 -0400 schrieb isabelle:

Sub test_Last()
'LastRow
LastRow = Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

'LastColumn
LastColumn = Cells.Find("*", LookIn:=xlValues, _
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

Application.Goto Range(Cells(1, 1), Cells(LastRow, LastColumn))
End Sub


the OP looks for the last row of the PAGE not the last row of the sheet.
But if there is only 1 page into the sheet HPageBreaks.Count = 0 and
HPAgeBreaks.Location fails


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default How to determine Last row of a Page in Excel

Hi,

Am Wed, 21 Aug 2013 11:20:26 +0100 schrieb divya nila:

I want to add Page border (for four sides) around each page in the
spreadsheet of excel. My excel is having multipages in one spreadsheet
and it is having nearly 6 spreadsheets. I have used PageBreaks to
determine last row of a page but the pagebreak is 0 if i have only one
page in a spreadsheet. So i want to know how to determine the last row
of a page.


try:
Sub PageBreak()
Dim intHPB As Integer

With ActiveSheet
If .HPageBreaks.Count = 0 Then .Cells(65, 1) = "Test"
MsgBox .HPageBreaks(1).Location.Row - 1
.Cells(65, 1).Clear
End With
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #8   Report Post  
Junior Member
 
Posts: 3
Default

hi Busch,

thank you for the suggestion. But i am looking forward to a code without hardcoding. I have tried already what you have suggested. But our users doesn't like it.


Quote:
Originally Posted by Claus Busch View Post
Hi,

Am Wed, 21 Aug 2013 11:20:26 +0100 schrieb divya nila:

I want to add Page border (for four sides) around each page in the
spreadsheet of excel. My excel is having multipages in one spreadsheet
and it is having nearly 6 spreadsheets. I have used PageBreaks to
determine last row of a page but the pagebreak is 0 if i have only one
page in a spreadsheet. So i want to know how to determine the last row
of a page.


try:
Sub PageBreak()
Dim intHPB As Integer

With ActiveSheet
If .HPageBreaks.Count = 0 Then .Cells(65, 1) = "Test"
MsgBox .HPageBreaks(1).Location.Row - 1
.Cells(65, 1).Clear
End With
End Sub


Regards
Claus B.
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How excel determine how many rows fit in to every page? Smitesh Tamboli[_2_] Excel Programming 1 February 12th 09 01:40 PM
To determine that cell is on top of page Andrei Zakharov Excel Programming 1 September 3rd 08 04:40 PM
How to programmatically determine actual page count in Excel 2003? GopherDude Excel Programming 0 September 4th 07 08:46 PM
Determine last row before end of page on worksheet dclarkston Excel Programming 1 September 16th 05 07:25 AM
Determine page which row will print on Fred Smith Excel Programming 0 July 22nd 04 05:49 AM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"