Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to print a named range 1

Status
Not open for further replies.

jan149

MIS
Feb 24, 2009
2
US
Hi,

I have a spreadsheet form with many sections in it. I have created named ranges for each section and would like to create a macro to print just that section of the form. (this is Excel 2003). (I am not a developer, just trying to work on some improvements in a paper form process!)

I recorded a macro to select the print area and then printed the selected area.

Instead of referencing a hard range, such as A1:G4, I'd like it to reference my named range, such as range1.

The range exists in sheet 1. I looked in Microsoft Help and to reference a named range and it said "The following example refers to the worksheet-specific range named "Sheet1!Sales" in the workbook named "Report.xls."

Sub FormatSales()
Range("[Report.xls]Sheet1!Sales")."

Sub PRINT_UAM_P_AP()
'
' PRINT_UAM_P_AP Macro
' Macro recorded 2/23/2009 by DOI
'

'
Range("A260:E333").Select
Selection.PrintOut Copies:=1, Collate:=True
End Sub


I tried to change my refence in my range to my named ranges but it isn't workin.

The sheet name: UAM-P
Workbook name: UAM-P
Named range: UAM_P_AC (exists in the sheet UAM_P)

worksheet-specific range named "Sheet1!Sales" in the workbook named "Report.xls.".

when I run it, I get the Run time error 1004, Method "range" of object _global failed. Do I need to declare my ranges somewhere?

Sub FormatSales()
Range("[UAM-P.xls]UAM-P!UAM_P_AC").select
 
Have you tried this ?
Sheets("UAM-P").Range("UAM_P_AC").PrintOut Copies:=1, Collate:=True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Usually range names are not specific to a particular sheet. So you don't need the [red]sheets("UAM").[/red] part at all.




Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top