Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello all, I hope someone can answer what may be a dumb question. Is it possible to execute a procedure from a variable? For example, if cell A1 has the value of "Macro_1" and I have a sub named Macro_1 is there some way to read cell A1 and convert that value into a sub name I can execute? I hope that made sense. lol Thanks for any tips you can give. -- Redbeard ------------------------------------------------------------------------ Redbeard's Profile: http://www.excelforum.com/member.php...o&userid=24612 View this thread: http://www.excelforum.com/showthread...hreadid=536813 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I've wished for that but I don't think it's possible. You could do
something like this of course: Select Case Range("A1").Value Case "Sub1": Sub1 Case "Sub2": Sub2 Case "Sub3": Sub3 End Select -- Jim "Redbeard" wrote in message ... | | Hello all, I hope someone can answer what may be a dumb question. Is it | possible to execute a procedure from a variable? For example, if cell | A1 has the value of "Macro_1" and I have a sub named Macro_1 is there | some way to read cell A1 and convert that value into a sub name I can | execute? I hope that made sense. lol | | Thanks for any tips you can give. | | | -- | Redbeard | ------------------------------------------------------------------------ | Redbeard's Profile: http://www.excelforum.com/member.php...o&userid=24612 | View this thread: http://www.excelforum.com/showthread...hreadid=536813 | |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
Can you not use Application.Run. Run the routine Test where cell A1 contains Macro1. ' Place in standard code module. Sub Macro1() MsgBox "Macro1" End Sub Sub Macro2() MsgBox "Macro2" End Sub Sub Macro3() MsgBox "Macro3" End Sub Sub Test() Application.Run Range("A1").Value End Sub Cheers Andy Redbeard wrote: Hello all, I hope someone can answer what may be a dumb question. Is it possible to execute a procedure from a variable? For example, if cell A1 has the value of "Macro_1" and I have a sub named Macro_1 is there some way to read cell A1 and convert that value into a sub name I can execute? I hope that made sense. lol Thanks for any tips you can give. -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Don't think you can, at least not in office XP - it gives an
application or object defined error message |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Works for me in both Xl2000 and xl2003.
Where abouts does it actually error out? wrote: Don't think you can, at least not in office XP - it gives an application or object defined error message -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
in the Application.Run Range("A1").Value bit of code - mind you, with
our odd office settings, anything is possible (office network boys had a field day "standardising" pc's!!!) |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Did you put the name of an existing procedure in A1 of that activesheet?
wrote: Don't think you can, at least not in office XP - it gives an application or object defined error message -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a macro called A, and cell A1 has A in it, so yes, BUT I've
figured out the solution - IF the macro is stored in a module it works fine, but if it is on the workbook/worksheet then it won't. Which is therefore a consideration that needs to be bourne in mind when creating this type of macro! |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I did included a code comment about putting it all in a standard module.
If the code is in a worksheet object, for example sheet1, then this should work. Cell contains Sheet1.Macro1 Cheers Andy AidanH wrote: I have a macro called A, and cell A1 has A in it, so yes, BUT I've figured out the solution - IF the macro is stored in a module it works fine, but if it is on the workbook/worksheet then it won't. Which is therefore a consideration that needs to be bourne in mind when creating this type of macro! -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to Dim the contents of a variable in running procedure? | Excel Discussion (Misc queries) | |||
Variable procedure call | Excel Programming | |||
Call procedure using variable | Excel Programming | |||
Public/Procedure Variable | Excel Programming | |||
can I call a procedure using a variable | Excel Programming |