Create a pop up

dvuppx

New Member
Joined
Aug 31, 2017
Messages
12
i have a document that is shared by 5 different people in our office, and often people forget to leave it open. Im struggling to write a macro that would make a pop up appear every 15 minutes to remind people to close the document if they are finished editing it. any suggestions?
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Re: how to create a pop up

The below should work:

Code:
Private Sub Workbook_Open()
  
Application.ontime Now + TimeValue("00:15:00"), "TimeMsg"
MsgBox "Please remember to close this workbook"
 
End Sub

You will need to put it in the Thisworkbook object so it starts running when you open the file
 
Last edited:
Upvote 0
Re: how to create a pop up

Create a new module in VBA and paste the following:

Code:
Private scheduledToRun As Boolean
Private runTime As Variant
Public Sub SheetChange()

Call CancelMacro
runTime = Now + TimeSerial(0, 15, 0)
Application.OnTime EarliestTime:=runTime, Procedure:="CloseReminder"
scheduledToRun = True

End Sub
Public Sub CloseReminder()

scheduledToRun = False
If MsgBox("You've been inactive for 15 minutes. Do you need to close the spreadsheet?", vbQuestion + vbYesNo) = vbYes Then
    ActiveWorkbook.Close
Else
    Call SheetChange
End If

End Sub
Public Sub CancelMacro()

If scheduledToRun Then Application.OnTime EarliestTime:=runTime, Procedure:="CloseReminder", Schedule:=False

End Sub

Now select the "ThisWorkbook" module and paste the following:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)

Call CancelMacro

End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

Call SheetChange

End Sub

WBD
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
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