View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
jfarrug jfarrug is offline
external usenet poster
 
Posts: 2
Default Print Area to last cell with data

On Jul 8, 4:01 pm, Susan wrote:
Help,

we are constantly adding new data and trying to write a macro (which I am
new to) that will set the print area automatically to the last row with data
in it. Can someone please help me.... I have no idea what i am doing and
the people i am writing this for have less knowledge.

Any help would be appreciated!


try the following macro strip, Of course you will have to determine
where the end of the data is located (i call it lastpos)

ActiveSheet.PageSetup.PrintArea = Range(Cells(1, 1), Cells(lastpos,
15)).Address
printsetup

Application.ScreenUpdating = True

Function printsetup()

With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = "&D"
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = True
.PrintComments = xlPrintNoComments
.PrintQuality = 300
.CenterHorizontally = True
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
End Function