Close message box after interval

60john

Board Regular
Joined
Apr 25, 2013
Messages
80
Hi there,

I imagine there is a simple solution to this but I can not find an answer to it.

I would like the message box in the following code to close automatically after say 5 seconds. I am guessing that a user form might be the way to go but will defer to wiser council.

Code:
Option Explicit
Private Sub Workbook_Open()
    MsgBox "Note that the prices in italics are indicative only. ", vbOKOnly
End Sub

Thanks in advance
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I found this solution elsewhere.

Show user form for specific time interval then close form

Coded as follows:

Code:
Private Sub Workbook_Open()
    UserForm1.Show vbModeless
    
    Application.OnTime Now + TimeValue("00:00:03"), "unloadit"
End Sub
Public Sub unloadit()
Unload UserForm1
End Sub

The first part, popping up the user form works fine. But the second part does not. I get a pop up error telling me that the macro may not be available in this workbook or all macros may be disabled.

Any ideas?
 
Upvote 0
I don't know what I was doing wrong VoG. I copied the code directly into a module but still had to click the OK button to clear the message.

I did get the other solution I found working, by the way. I just had to have the public sub in a module and not in the This Workbook
 
Upvote 0

Forum statistics

Threads
1,222,170
Messages
6,164,382
Members
451,886
Latest member
elpepe1970

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