Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Call a subroutine using variable subroutine name
If I have a cell with the contents of a subroutine name for example
A1 = "Mysub" So if I do Dim CodeToExecute As String CodeToExecute = Range("A1").Value I want to call Mysub using the variable CodeToExecute Any help is appreciated. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Call a subroutine using variable subroutine name
Try this
Application.Run Sheets("Sheet1").Range("A1").Text Mike "dhstein" wrote: If I have a cell with the contents of a subroutine name for example A1 = "Mysub" So if I do Dim CodeToExecute As String CodeToExecute = Range("A1").Value I want to call Mysub using the variable CodeToExecute Any help is appreciated. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Call a subroutine using variable subroutine name
For example:
Sub Mysub() MsgBox ("HELLO") End Sub Sub dhstein() Dim CodeToExecute As String CodeToExecute = Range("A1").Value Application.Run (CodeToExecute) End Sub -- Gary''s Student - gsnu200859 "dhstein" wrote: If I have a cell with the contents of a subroutine name for example A1 = "Mysub" So if I do Dim CodeToExecute As String CodeToExecute = Range("A1").Value I want to call Mysub using the variable CodeToExecute Any help is appreciated. |
#4
Posted to microsoft.public.excel.misc
|
|||
|
|||
Call a subroutine using variable subroutine name
Thanks Mike and Gary - that worked well.
David "Mike H" wrote: Try this Application.Run Sheets("Sheet1").Range("A1").Text Mike "dhstein" wrote: If I have a cell with the contents of a subroutine name for example A1 = "Mysub" So if I do Dim CodeToExecute As String CodeToExecute = Range("A1").Value I want to call Mysub using the variable CodeToExecute Any help is appreciated. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Stopping a userform subroutine | Excel Discussion (Misc queries) | |||
halt a subroutine question | Excel Discussion (Misc queries) | |||
SUBROUTINE HELP | Excel Discussion (Misc queries) | |||
How to use this subroutine on multiple cells? | Excel Worksheet Functions | |||
How do I exit a macro subroutine? | Excel Worksheet Functions |