calling subroutine in VBA

JoeS01

Well-known Member
Joined
Jun 25, 2005
Messages
832
I have a procedure which calls a number of different subroutine procedures, and wish to make them generic. Can anyome please advise how I might do this, something like in the attached code below??

I will appreciate all suggestions and direction.



Code:
dim  myProcedureName as String

myProcedureName = "Utils.TestData"   'this is the module.procedure I wish to use

Call myProcedureName

This obvviously will not work as shown, as the Call statement looks for a Procedure
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Try this way of calling your custome procedure.

Sub StartDoingIt()
DoItAgain
End Sub

Sub DoItAgain()
'calculate when code should run again
dNext = Now + TimeValue("00:15:00")
'set on time event to trigger running
Application.OnTime dNext, "DoItAgain"
' whatever you want to do
Envisage_calls_status
End Sub


So the procedure StatDoingIt calls the sub DoItAgain, which in turn calls another sub routine or procedure.
 
Upvote 0
thanks for these suggestions. I have found that the correct method to run a macro called TestMacro is:

Code:
dim procedureName as string

procedureName =" TestMacro"

application.run(procedureName)
 
Upvote 0

Forum statistics

Threads
1,215,417
Messages
6,124,791
Members
449,188
Latest member
Hoffk036

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top