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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top