Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Same macro to work on different ranges?
Private Sub CommandButton1_Click() Application.Goto Reference:="NamedRange1" Call Macro1 End Sub Private Sub CommandButton1_Click() Application.Goto Reference:="NamedRange2" Call Macro1 End Sub Gord Dibben MS Excel MVP On Thu, 1 Apr 2010 12:46:05 -0700, hjc wrote: I have written a macro that I would like to have operate the same way on different data ranges. I tried creating a generic macro that accepted a range of data as an input parameter, then I created several buttons that each called the same macro, but with a different argument, as follows: Private Sub CommandButton1_Click() Call Macro1( "NamedRange1" ) End Sub Private Sub CommandButton2_Click() Call Macro1( "NamedRange2" ) End Sub and so on. However, I can't seem to find the right syntax for specifying a range name in the call to the macro (if there is one). Even if I have to use cell references instead of a named range, I could live with that. Does anybody know if there is a way to do this? Thanks! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Named Range Macro | Excel Discussion (Misc queries) | |||
Trying to call a macro on selection of a cell in a range | Excel Programming | |||
How to set named range in macro? | Excel Programming | |||
Call Macro when Cell within Range Changes | Excel Programming | |||
Passing a range in a macro call | Excel Programming |