1

I'm using Application run to call several macros in order like this.

Sub Run_All_Macros()
  Application.Run ("Macro_1")
  Application.Run ("Macro_1")
End Sub

When I start Run_All_Macros, all the macros run in parallel. Is there a way to wait for the first macro to complete before the second is started?

Community
  • 1
  • 1
noel_g
  • 279
  • 1
  • 6
  • 17
  • 2
    This seems odd. `Application.Run` is synchronous. The call to Application.Run("Macro_1") will not return until the macro has finished executing. That said, if the macro starts an asynchronous process, then you might get the effect you describe. What do the macros do, and what evidence do you have that the macros are running in parallel? – Gary McGill Nov 09 '09 at 20:44
  • The first one copies the contents of a file from a network share, the second adds a formula to a column. I believe they run at the same time because I see the formula being filled in and overwritten by a Paste when the first macro has the file open and does the copy of its contents. – noel_g Nov 09 '09 at 21:05

1 Answers1

4

If you step through the macros (Use F8) you should see that they are running in order and not simultaneously.

I use the step through method to watch exactly what is happening and in what order. I often find I've included an error in logic, or something else, that doesn't give the desired result.

guitarthrower
  • 5,624
  • 3
  • 29
  • 37