display messagebox on time

deanop2

New Member
Joined
Jan 29, 2021
Messages
19
Office Version
  1. 2013
Platform
  1. Windows
I'm trying to get a messagebox to open and display a message, I found this code below but it doesn't work
I've tried putting the Private Sub in the workbook and the Sub Display Alarm() in a module but nothing happens.


Private Sub Workbook_Open()
Application.OnTime TimeValue("17:24:00"), "DisplayAlarm()"
End Sub

Sub DisplayAlarm()
MsgBox "Good Morning"
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Just remove the () parentheses:
VBA Code:
Application.OnTime TimeValue("17:24:00"), "DisplayAlarm"
 
Upvote 0
Put all the VBA code in the "ThisWorkbook" module in VBA.
"Workbook_Open" event procedures only run automatically when placed in that particular module.
 
Upvote 0
Put all the VBA code in the "ThisWorkbook" module in VBA.
"Workbook_Open" event procedures only run automatically when placed in that particular module.
I've followed the instructions and nothing happens when the time elapses. removed the () and put the code in a module.
 
Upvote 0
I've followed the instructions and nothing happens when the time elapses. removed the () and put the code in a module.
After making the changes, did you close your workbook and then re-open it?

The Workbook_Open event procedure only kicks off when a workbook is first opened.
So if you make changes to it during your session, you need to close it and re-open it to kick off the changes you made.
 
Upvote 0
After making the changes, did you close your workbook and then re-open it?

The Workbook_Open event procedure only kicks off when a workbook is first opened.
So if you make changes to it during your session, you need to close it and re-open it to kick off the changes you made.
cant figure this out, followed everything and doesnt activate, i've run the message box and it does open but not from the time.
1. change the time
2. save and close
3. reopen, wait
4 time passes, nothing...
 

Attachments

  • message.png
    message.png
    70.1 KB · Views: 5
Upvote 0
No, you did not put in the correct place! I said you have to put it in the ThisWorkbook module. You have put it in a General module (Module1).
"Workbook_Open" absolutely MUST be in the ThisWorkbook module! That is the only place the will run automatically!

It needs to go in the module I circled off of your screen print.

1715280835054.png
 
Upvote 0
No, you did not put in the correct place! I said you have to put it in the ThisWorkbook module. You have put it in a General module (Module1).
"Workbook_Open" absolutely MUST be in the ThisWorkbook module! That is the only place the will run automatically!

It needs to go in the module I circled off of your screen print.

View attachment 111179
I'd had it in there b4 and I did misread your response. it was the close and reopen issue. moved it back reopened and it works, thanks :)
 
Upvote 0

Forum statistics

Threads
1,223,892
Messages
6,175,236
Members
452,621
Latest member
Laura_PinksBTHFT

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