[RESOLVED] VB code to set spreadsheet PrintArea Range

Hi,
I need help setting a spreadsheet printing Range because when I print, after printing the area with data, it prints additional blank pages.

So how can I set my print range from "A1" to the last cell that has data?

Example:

xlWksht.PageSetup.PrintArea = xlWksht.Range("A1:???").Address

Note: in the code above, I do not have idea where the range with data ends.

Thanks.
GiftX
[431 byte] By [Giftx] at [2007-11-20 10:57:45]
# 1 Re: [RESOLVED] VB code to set spreadsheet PrintArea Range
Google'd again :confused:

Sub Macro1()
'
' Macro1 Macro
'
Range("E4").End(xlDown).Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.PrintPreview
End Sub


read the bottom http://www.ozgrid.com/VBA/ExcelRanges.htm
dglienna at 2007-11-9 19:34:12 >
# 2 Re: [RESOLVED] VB code to set spreadsheet PrintArea Range
Hi dg,
why am I selecting Range("E4").End(xlDown)?
In my spreadsheet, the data starts from Range("A:N") and goes down to an unspecified rage of cells. That's why I am looking for a code that specify only the range with data.
Thanks.
GiftX.
Giftx at 2007-11-9 19:35:07 >
# 3 Re: [RESOLVED] VB code to set spreadsheet PrintArea Range
that selected the range on my worksheet. you would use the same type code. did you read that page? it said my first method didn't work with vba, and gave the alternatives.
dglienna at 2007-11-9 19:36:17 >