PC Review


Reply
Thread Tools Rate Thread

Code modification help please

 
 
=?Utf-8?B?VG9t?=
Guest
Posts: n/a
 
      10th Apr 2007
Hi all,
I could sure use some help with the following code. I'm using this to set
the print area on a sheet. The problem is, that it is shrinking the selection
WAY too small - not to "fit to page" as I was wanting it to. Any
suggestions???

Thanks,
Tom

Lrow = ActiveSheet.Range("A:O").SpecialCells(xlCellTypeLastCell).Row
With ActiveSheet.PageSetup
.PrintArea = "$A$1:$O$" & Lrow
.Zoom = False
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      10th Apr 2007
I suspect that lrow is overstated.

sub SetPrintArea()
Dim Lrow as Long
Lrow = GetRealLastCell(Activesheet).row
With ActiveSheet.PageSetup
.PrintArea = "$A$1:$O$" & Lrow
.Zoom = False
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.FitToPagesWide = 1
.FitToPagesTall = 1
End With

End Sub

Function GetRealLastCell(sh as Worksheet) as Range
Dim RealLastRow As Long
Dim RealLastColumn As Long
On Error Resume Next
RealLastRow = _
sh.Cells.Find("*", sh.[A1], , , xlByRows, xlPrevious).Row
RealLastColumn = _
sh.Cells.Find("*", sh.[A1], , , xlByColumns, xlPrevious).Column
set GetRealLastCell = sh.Cells(RealLastRow, RealLastColumn)
End Function

--
Regards,
Tom Ogilvy


"Tom" wrote:

> Hi all,
> I could sure use some help with the following code. I'm using this to set
> the print area on a sheet. The problem is, that it is shrinking the selection
> WAY too small - not to "fit to page" as I was wanting it to. Any
> suggestions???
>
> Thanks,
> Tom
>
> Lrow = ActiveSheet.Range("A:O").SpecialCells(xlCellTypeLastCell).Row
> With ActiveSheet.PageSetup
> .PrintArea = "$A$1:$O$" & Lrow
> .Zoom = False
> .LeftMargin = Application.InchesToPoints(0.5)
> .RightMargin = Application.InchesToPoints(0.5)
> .TopMargin = Application.InchesToPoints(0.5)
> .BottomMargin = Application.InchesToPoints(0.5)
> .FitToPagesWide = 1
> .FitToPagesTall = 1
> End With

 
Reply With Quote
 
=?Utf-8?B?VG9t?=
Guest
Posts: n/a
 
      10th Apr 2007
Thanks Tom!

"Tom Ogilvy" wrote:

> I suspect that lrow is overstated.
>
> sub SetPrintArea()
> Dim Lrow as Long
> Lrow = GetRealLastCell(Activesheet).row
> With ActiveSheet.PageSetup
> .PrintArea = "$A$1:$O$" & Lrow
> .Zoom = False
> .LeftMargin = Application.InchesToPoints(0.5)
> .RightMargin = Application.InchesToPoints(0.5)
> .TopMargin = Application.InchesToPoints(0.5)
> .BottomMargin = Application.InchesToPoints(0.5)
> .FitToPagesWide = 1
> .FitToPagesTall = 1
> End With
>
> End Sub
>
> Function GetRealLastCell(sh as Worksheet) as Range
> Dim RealLastRow As Long
> Dim RealLastColumn As Long
> On Error Resume Next
> RealLastRow = _
> sh.Cells.Find("*", sh.[A1], , , xlByRows, xlPrevious).Row
> RealLastColumn = _
> sh.Cells.Find("*", sh.[A1], , , xlByColumns, xlPrevious).Column
> set GetRealLastCell = sh.Cells(RealLastRow, RealLastColumn)
> End Function
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Tom" wrote:
>
> > Hi all,
> > I could sure use some help with the following code. I'm using this to set
> > the print area on a sheet. The problem is, that it is shrinking the selection
> > WAY too small - not to "fit to page" as I was wanting it to. Any
> > suggestions???
> >
> > Thanks,
> > Tom
> >
> > Lrow = ActiveSheet.Range("A:O").SpecialCells(xlCellTypeLastCell).Row
> > With ActiveSheet.PageSetup
> > .PrintArea = "$A$1:$O$" & Lrow
> > .Zoom = False
> > .LeftMargin = Application.InchesToPoints(0.5)
> > .RightMargin = Application.InchesToPoints(0.5)
> > .TopMargin = Application.InchesToPoints(0.5)
> > .BottomMargin = Application.InchesToPoints(0.5)
> > .FitToPagesWide = 1
> > .FitToPagesTall = 1
> > End With

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code modification? =?Utf-8?B?ZnBkODMz?= Microsoft Excel Programming 2 21st Sep 2007 04:52 PM
Code modification please =?Utf-8?B?VG9t?= Microsoft Excel Programming 3 27th Apr 2007 02:22 PM
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) Thulasiram Microsoft Excel Programming 4 26th Sep 2006 04:15 AM
Code Modification =?Utf-8?B?U2t5IFdhcnJlbg==?= Microsoft Access Form Coding 1 17th Mar 2005 07:48 PM
Code modification Mas Microsoft Excel Programming 3 29th Mar 2004 09:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:14 AM.