Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code modification help please
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(xlCellTypeLa stCell).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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code modification help please
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(xlCellTypeLa stCell).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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Code modification help please
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(xlCellTypeLa stCell).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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Code modification help | Excel Worksheet Functions | |||
Code modification help please | Excel Programming | |||
Modification in the CODE to HIDE rows and columns that start with ZERO (code given) | Excel Programming | |||
modification for the code | Excel Programming | |||
Modification to code | Excel Programming |