I need help to merge 2 macros VBA CODE

[Closed]
Report
-
Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
-
Hello,

I need help to merge 2 macros. Bascially, after "MACRO1" finishes running in File 1 ( macro 1 itself located in file 1), i want excel to run " MACRO 2" in File 2 (macro 2 itself located in file 2) . I tried using the following code:

Windows("2.xls").Activate
Application.Run "2.xls!Macro2"

However, Instead of running in file 2, it runs in file 1 which overwrite all the original data i had in File 1. ( It goes back to 1.xls even i gave the code Windows("2.xls").Activate)

My target:
After excel finished all the updates in file 1 by macro 1, i would like macro 2 to excute the command i put in macro 1 in file 2. What can i do to tell excel to run in the different file instead of the one file that i wrote the codes on?I need a VBA code that can help me to achiece this. Can anyone help??

Thanks.

1 reply

Posts
4476
Registration date
Thursday January 28, 2010
Status
Contributor
Last seen
August 2, 2020
768
Why not house both macro in same book ?