macro message box

JasonLeVan

Board Regular
Joined
Feb 7, 2011
Messages
121
Is there a way to have a message box pop up but continue running the rest of my macro
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Jason,

The important term you want to know is 'Modal.' A modal form or dialog is one that is going to cause it's parent to stop running until its own process is finished (sorry if you knew that already).

I am pretty confident that that VBA msgbox is always modal. There's no way to put one on the screen and have the macro that created it continue running.

However, Userforms can be non-modal. You can set up a userform to look a lot like a msgbox, if you want.

Code:
UserForm1.Show vbModeless

There may be better solutions, but this is how I'd do it. Remeber that you'll have to figure out when you want the userform to go away and either hide or unload it as necessary.
 
Upvote 0
Do you mean show a msgbox, dismiss it automatically and then continue with the rest of of the macro? If so, this will display a msgbox for 2 seconds, dismiss and then run the rest of the macro.

Code:
Public Sub test()
    Dim objWShell As Object, i
    Set objWShell = CreateObject("Wscript.Shell")
    
    objWShell.Popup "Boo!", 2
    
    'rest of macro
    
    MsgBox "done"
End Sub
 
Upvote 0
this will work great, how do i hide it when i am done with the display

Jason,

The important term you want to know is 'Modal.' A modal form or dialog is one that is going to cause it's parent to stop running until its own process is finished (sorry if you knew that already).

I am pretty confident that that VBA msgbox is always modal. There's no way to put one on the screen and have the macro that created it continue running.

However, Userforms can be non-modal. You can set up a userform to look a lot like a msgbox, if you want.

Code:
UserForm1.Show vbModeless

There may be better solutions, but this is how I'd do it. Remeber that you'll have to figure out when you want the userform to go away and either hide or unload it as necessary.
 
Upvote 0
Sorry for the long wait. Had a tough week over here :(


You can hide the userform and keep it around in memory. This is kind of nice if you find yourself wanting to build onto information that you've already put into the form once already. Just remember to unload it later on.

Code:
'from somewhere other than the userform
Userform1.Hide
 
'from the code launched from the form itself (like a button event)
Me.Hide

If you're done with it and you don't want invisible forms hogging up your resources, use unload.

Code:
'from somewhere other than the userform
Unload Userform1
 
'from the code launched from the form itself (like a button event)
Unload Me
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,848
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top