Hi @Xu, Jia/许 佳,
Thank you for posting your question in the Microsoft Q&A forum!
Regarding that you want to run 2 identical VBA programs simultaneously.
Running two VBA macros simultaneously is generally not supported directly within Excel or other Office applications, because VBA runs in a single-threaded environment. However, there are a few workarounds depending on what you're trying to achieve:
Use Application.OnTime to Schedule Macros
You can schedule one macro to run slightly after another using Application.OnTime.
Sub RunMacro1()
' Your first macro code here
MsgBox "Macro 1 running"
' Schedule Macro2 to run in 1 second
Application.OnTime Now + TimeValue("00:00:01"), "RunMacro2"
End Sub
Sub RunMacro2()
MsgBox "Macro 2 running"
End Sub
To demonstrate this, I tested the following setup:
- Macro1 fills cells A1:A5 with numbers.
- Macro2 highlights cells B1:B5 in yellow.
- After running RunMacro1, it completes the task and notifies me. Then, RunMacro2 is triggered automatically after a short delay.
If I’ve misunderstood anything, please feel free to correct me. I just want to make sure I fully understand so I can support you better.
Thank you again for your time and understanding. While my initial response may not resolve the issue immediately, I’d like to gather more details about your situation so I can assist you more effectively.
I really appreciate your patience, and I’m here to help. Looking forward to your response!
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread