Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keep working while Message Box is displayed

Tags:

excel

vba

I am running a code on vba and I display the results using the MsgBox. I want to keep these results displayed as I enter the result values in a separate excel file but Excel doesn't allow me to work on another excel file until I press OK or Cancel button on MsgBox. How do keep msgbox on and still work on the separate excel file ?

like image 338
user2436437 Avatar asked Sep 19 '25 18:09

user2436437


1 Answers

Don't use a MsgBox. Use a customized Userform instead and then call it showing it as modeless

UserForm1.Show vbModeless

For example

Sub Sample()
    '
    '~~> Rest of your code
    '
    MsgBox "Hello World"
    '
    '~~> Rest of your code
    '
End Sub

can be also written as

Sub Sample()
    '
    '~~> Rest of your code
    '
    UserForm1.Label1.Caption = "Hello World"
    UserForm1.Show vbModeless
    '
    '~~> Rest of your code
    '
End Sub
like image 197
Siddharth Rout Avatar answered Sep 23 '25 12:09

Siddharth Rout