View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
TRYING TRYING is offline
external usenet poster
 
Posts: 39
Default Macro print range not dynamic like I wanted it to be

Thanks Gord. I also tried your solution and it works as far as print range
selection is concerned, but it also altered the print setup in other ways
that didn't suit my purpose.

"Gord Dibben" wrote:

Sub DataPrint()
'
' DataPrint Macro
'
' Keyboard Shortcut: Ctrl+d
'
Application.Goto Reference:="DataTopLeft"
ActiveSheet.PageSetup.PrintArea = CurrentRegion
ActiveWindow.SelectedSheets.PrintPreview
End Sub


Gord Dibben MS Excel MVP

On Mon, 26 Nov 2007 13:21:00 -0800, TRYING
wrote:

Sub DataPrint()
'
' DataPrint Macro
'
' Keyboard Shortcut: Ctrl+d
'
Application.Goto Reference:="DataTopLeft"
Selection.CurrentRegion.Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$E$209"
ActiveWindow.SelectedSheets.PrintPreview
End Sub

Above is a macro I recorded. "DataTopLeft" is cell A1 which contains a
non-printing apostrophe. When recording the macro I started by going to
DataTopLeft. Then I clicked on Select Current Region icon which defined the
region as "$A$1:$E$209". Then I clicked the Set Print Area icon. Then I
clicked on the Print Preview icon. I then clicked the Stop Recording icon.

The print area for next month could be A1 to E215 or A1 to E198 or some
other area.

How can I make the macro do what I want and what I thought I did when I
recorded it, which is select the current range and set that as the print
range?

Thanks.