Pass contents of a cell to a macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a cell (called Print_Range). I want to call a macro to set the print
range to the contents of Print_Range e.g. $A$1:$E$55
 
Sub Macro()
Dim s As String
Dim ss As String
Dim r As Range
ss = "Print_Range"
Set r = Range(ss)
s = r.Value
ActiveSheet.PageSetup.PrintArea = s
End Sub

This assumes that you have done two things already:

1. created the Name
2. put the range information into it

Have a good day
 
Spot On. Works a treat. Many thanks

Gary''s Student said:
Sub Macro()
Dim s As String
Dim ss As String
Dim r As Range
ss = "Print_Range"
Set r = Range(ss)
s = r.Value
ActiveSheet.PageSetup.PrintArea = s
End Sub

This assumes that you have done two things already:

1. created the Name
2. put the range information into it

Have a good day
 
Back
Top