Perhaps this is a straightforward question, but I need to 100% verify this. I have a function (Execute) that calls different modules in order.. Like this:
Private Sub Execute() Call Func1 Call Func2 Call Func3 End Sub
Functions 1 and 2 are quite complicated functions that draws and manipulates data. What is very important is that functions 1 and 2 are executed and completed prior to running function 3.
One way I do this currently is by forcing a 1 second lag prior function 3 to ensure 1 and 2 are finished, something like this:
Private Sub Execute() Call Func1 Call Func2 Application.Wait (Now + TimeValue("0:00:01")) Call Func3 End Sub
I am thinking of removing the 1 second lag – but I really want to make sure that functions are running and completing in a synchronized manner.
I am pretty certain that VBA function calls would be synchronous, but one easy way you could verify this would be to put
debug.print statements inside your functions. In
debug.print "Entering Func1" as the very first statement and
debug.print "Exiting Func1" as the very last statement. Put equivalent statements in the other two functions. After you run your
Execute function, examine the debug window to check that all the messages come out in the expected order.