Automatically Create Message Box with Timer @Exceltrainingvideos
Automatically Create Message Box with Timer  @Exceltrainingvideos
Uploaded January 2020 | Updated September 2026, 2 weeks ago
How to create a message box automatically that closes itself after a specific time using VBA.
Here's the complete VBA code:
Private Sub Workbook_Open()
startTimer
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
startTimer
End Sub

Option Explicit

Const PopupDurationSecs As Integer = 5

Sub startTimer()
Application.OnTime Now + TimeValue("00:00:05"), "myShellMessageBox"
End Sub
Sub myShellMessageBox()

Dim Result As Integer

Result = CreateObject("WScript.Shell").PopUp( _
"Keep this workbook open?", PopupDurationSecs, _
"Keep Workbook Open", 4 + 32)
'MsgBox Result
If Result = 6 Then
Exit Sub
ElseIf Result = 7 Then
'ThisWorkbook.Save
Application.Quit
End If
End Sub

For more on this method see the MSDN documentation at msdn.microsoft.com/en-us/library/x83z1d9f%28v=VS.85%29.aspx
Automatically Create Message Box with TimerHow to disable print optionUsing ADO and SQL with VBAWorksheet Change Event Macro to Manipulate DataSearch Data in Multiple Workbooks AutomaticallyConvert Multiple Sheets To Multiple PDF FilesPrevent Worksheet Name ChangeImport Data from Multiple Worksheets in Multiple Workbooks Using Power QueryPrint Selected RangeGet Data from Multiple CSV Text Files into Excel Worksheet
Dinesh Kumar Takyar |

Automatically Create Message Box with Timer

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER