• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 73
  • Last Modified:

Excel VBA - run a procedure decided at runtime

I'm writing generic code. I need to run a procedure, the name of which has been assigned to a string variable. Say, strMyProcedureToRun.

Sub GenericCode()

strMyProcedureToRun = "MyProcedure1"

[I need code here to run the procedure called MyProcedure1]

End Sub

Open in new window


Is that possible? And if so how?
Thanks
0
hindersaliva
Asked:
hindersaliva
  • 2
1 Solution
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
Like this...

Sub GenericCode()
Dim strMyProcedureToRun As String
strMyProcedureToRun = "MyProcedure1"
Application.Run strMyProcedureToRun
End Sub

Open in new window

0
 
hindersalivaAuthor Commented:
Thanks Neeraj!
That easy ...!
0
 
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now