![]() |
Pass contents of a cell to a macro
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 |
Pass contents of a cell to a macro
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 -- Gary's Student "Steve" wrote: 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 |
Pass contents of a cell to a macro
Spot On. Works a treat. Many thanks
"Gary''s Student" wrote: 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 -- Gary's Student "Steve" wrote: 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 |
Pass contents of a cell to a macro
You are very welcome
-- Gary''s Student "Steve" wrote: Spot On. Works a treat. Many thanks "Gary''s Student" wrote: 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 -- Gary's Student "Steve" wrote: 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 |
All times are GMT +1. The time now is 10:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com