How to run 2 identical VBA programs simultaneously (Excel for Windows)

Xu, Jia/许 佳 21 Reputation points
2025-10-17T06:43:30.89+00:00

i want to run 2 vbas in the same time,how can i do?

Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Henry-N 6,800 Reputation points Microsoft External Staff Moderator
    2025-10-17T08:43:43.8033333+00:00

    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. 
      User's image
    • After running RunMacro1, it completes the task and notifies me. Then, RunMacro2 is triggered automatically after a short delay. 
      User's image User's image

    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 


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.