Search code examples
excelmessageboxcountdowntimervba

Excel - Countdown Message box until Macro is Complete


I have a Macro which takes 45 seconds to complete. When the macro starts I want a Countdown timer to pop up like a message box which will countdown until Macro completion. I have searched but so far cant find any answers to this. Is this possible?


Solution

  • As @Thrum correctly mentioned in his comment this is not possible with a message box.

    A MsgBox is modal and therefore blocks the entire Excel application. Nothing else can happen / be done while that message box window is open and waits for you to close it. Actually, you can even make message boxes system-wide modal. In that case no other Windows application will respond unless you close that little message box in Excel (check the option vbSystemModal within the VBA help regarding MsgBox).

    However, with forms on the other hand you have a choice. You can make the form not modal.

    UserForm1.Show (False)
    

    In that case the code continues to run in the background while the form is shown to the user and permits the running VBA code to make changes to the form while it is shown to the user.