calling subroutine in VBA

JoeS01

Well-known Member
Joined
Jun 25, 2005
Messages
829
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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

jag108

Active Member
Joined
May 14, 2002
Messages
429
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
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.
 

JoeS01

Well-known Member
Joined
Jun 25, 2005
Messages
829
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)
 

Forum statistics

Threads
1,136,609
Messages
5,676,787
Members
419,651
Latest member
alexanderguhr

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
Top