Timed text box

tcebob

New Member
Joined
Apr 13, 2015
Messages
12
AVLm6B8


I'd like to have a text box appear after an event but only last for several seconds -- maybe 20. Just to verify that the event took place.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
It is an example, because there are several events that can occur on a sheet and you did not mention exactly which event.
Do the following:


1. Create a userform1 with a Label1
2. In the userform1, put the following code:

Code:
Private Sub UserForm_Activate()
    Label1.Caption = "The event took place"
    Application.OnTime Now + TimeValue("00:00:05"), "Close_Msg"
End Sub

INSERT A USERFORM
Press Alt-F11 to open the VBA editor. From the menu select Insert > Userform


3. In the events of your sheet, put the following code:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Address(False, False) = "C3" Then
        UserForm1.Show
    End If
End Sub


SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.


4. Create a module and put the following code:

Code:
Sub Close_Msg()
    unload UserForm1
End Sub


INSERT A MODULE
Press Alt-F11 to open the VBA editor. From the menu select Insert > Module. On the sheet that opens, paste the code previous.

-----


It works in the following way, when you select cell C3 the userform will open automatically and it will close after 5 seconds.
 
Upvote 0
More complex than I had hoped but I'll give it a go tomorrow. Thanks for the reply. The event was a save to .pdf.
 
Upvote 0
More complex than I had hoped but I'll give it a go tomorrow. Thanks for the reply. The event was a save to .pdf.

Your requirement is not simple.
If you only want a message after saving the pdf, then a msgbox appears and you close it with a click.

Code:
Sub Macro8()
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=ThisWorkbook.Path & "\" & "file.pdf"
    MsgBox "The event took place"
End Sub
 
Upvote 0
If I remember correctly, some people (quite a while ago now) said they had problems with the solution below, but I have never experience a problem with it myself. This single line of code will display a MessageBox for approximately 5 seconds (change the 5 for more or less display duration) after which code execution will continue. Of course, the user can dismiss the MessageBox earlier if desired.
Code:
CreateObject("WScript.Shell").PopUp "Your Message", [B][COLOR="#0000FF"]5[/COLOR][/B]

See this link for complete information about the various options available with this MessageBox...

http://msdn.microsoft.com/en-us/library/x83z1d9f(v=vs.85).aspx
 
Upvote 0
If I remember correctly, some people (quite a while ago now) said they had problems with the solution below, but I have never experience a problem with it myself. This single line of code will display a MessageBox for approximately 5 seconds (change the 5 for more or less display duration) after which code execution will continue. Of course, the user can dismiss the MessageBox earlier if desired.
Code:
CreateObject("WScript.Shell").PopUp "Your Message", [B][COLOR=#0000FF]5[/COLOR][/B]

See this link for complete information about the various options available with this MessageBox...

http://msdn.microsoft.com/en-us/library/x83z1d9f(v=vs.85).aspx

Thanks Rick, (saving the day). Works well in excel 2007
 
Upvote 0
Rick, I tried your suggestion, using "CreateObject("WScript.Shell").PopUp "Saved to Desktop", 5". The box appeared but did not turn itself off. I note that the Pop up method page is dated 2011. I am using Excel version 1905 so there may have been changes in the last 8 years.
 
Upvote 0
Rick, I tried your suggestion, using "CreateObject("WScript.Shell").PopUp "Saved to Desktop", 5". The box appeared but did not turn itself off. I note that the Pop up method page is dated 2011. I am using Excel version 1905 so there may have been changes in the last 8 years.

As Rick commented, some people had problems.
Try my solution.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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