Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting print area within macro
I have the following macro to select a specific worksheet and print based on
user input of worksheet name: Sub PrintWS() Dim ws As Worksheet Dim sName$ On Error GoTo ErrorInPrintWS sName = InputBox("Enter worksheet name", "Print") If sName < "" Then Set ws = Worksheets(sName) ws.PrintOut End If Exit Sub ErrorInPrintWS: Exit Sub End Sub I tried to alter it as follows to define a specific print range but was not successful. Sub PrintDeptArea() Dim ws As Worksheet Dim sName$ On Error GoTo ErrorInPrintWS sName = InputBox("Enter worksheet name", "Print") If sName < "" Then Set ws = Worksheets(sName) ActiveSheet.PageSetup.PrintArea = "$A$9:$R$74" ws.PrintOut End If Exit Sub ErrorInPrintWS: Exit Sub End Sub Can anyone help? Thanks, Tim |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting print area within macro
Sub PrintDeptArea()
Dim ws As Worksheet Dim sName$ On Error GoTo ErrorInPrintWS sName = InputBox("Enter worksheet name", "Print") If sName < "" Then Set ws = Worksheets(sName) ws.PageSetup.PrintArea = "'" & ws.Name & "'!$A$9:$R$74" ' ws.PrintOut End If Exit Sub ErrorInPrintWS: Exit Sub End Sub -- Regards, Tom Ogilvy "TimMalone" wrote in message ... I have the following macro to select a specific worksheet and print based on user input of worksheet name: Sub PrintWS() Dim ws As Worksheet Dim sName$ On Error GoTo ErrorInPrintWS sName = InputBox("Enter worksheet name", "Print") If sName < "" Then Set ws = Worksheets(sName) ws.PrintOut End If Exit Sub ErrorInPrintWS: Exit Sub End Sub I tried to alter it as follows to define a specific print range but was not successful. Sub PrintDeptArea() Dim ws As Worksheet Dim sName$ On Error GoTo ErrorInPrintWS sName = InputBox("Enter worksheet name", "Print") If sName < "" Then Set ws = Worksheets(sName) ActiveSheet.PageSetup.PrintArea = "$A$9:$R$74" ws.PrintOut End If Exit Sub ErrorInPrintWS: Exit Sub End Sub Can anyone help? Thanks, Tim |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Setting print area within macro
Tom,
Thanks! I works like a charm. "TimMalone" wrote: I have the following macro to select a specific worksheet and print based on user input of worksheet name: Sub PrintWS() Dim ws As Worksheet Dim sName$ On Error GoTo ErrorInPrintWS sName = InputBox("Enter worksheet name", "Print") If sName < "" Then Set ws = Worksheets(sName) ws.PrintOut End If Exit Sub ErrorInPrintWS: Exit Sub End Sub I tried to alter it as follows to define a specific print range but was not successful. Sub PrintDeptArea() Dim ws As Worksheet Dim sName$ On Error GoTo ErrorInPrintWS sName = InputBox("Enter worksheet name", "Print") If sName < "" Then Set ws = Worksheets(sName) ActiveSheet.PageSetup.PrintArea = "$A$9:$R$74" ws.PrintOut End If Exit Sub ErrorInPrintWS: Exit Sub End Sub Can anyone help? Thanks, Tim |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
setting the print area from a macro | Excel Worksheet Functions | |||
Macro script for setting Print Area | Excel Discussion (Misc queries) | |||
Setting the Print Area in a macro. | Excel Programming | |||
Setting Print Area | Excel Programming | |||
Setting print area | Excel Programming |