Application.OnTime can't see my macro

mrMadCat

New Member
Joined
Jun 8, 2016
Messages
39
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
I have this code in Workbook module:
Code:
Sub MESSAGE1()
msgBox "Change"
End Sub

Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
Application.OnTime Now + TimeValue("00:00:02"), "MESSAGE1"
End Sub
After 2 seconds it says that there is no such macro Message1. What did I miss? Thank you.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Edit... hold on a second...I am blinder than usual.
 
Last edited:
Upvote 0
Okay, not tried, but as I am reading it, it appears that you have MESSAGE1() in the ThisWorkbook Module, is that correct?
 
Upvote 0
Yes, it is in ThisWorkbook Module. I found a solution
Code:
Application.OnTime Now + TimeValue("00:00:02"), "ThisWorkbook.MESSAGE1"
But I'm using Russian version of excel and ThisWorkbook is called ЭтаКнига, so I have to write "ЭтаКнига.MESSAGE1".
I'm afraid it won't work if I run this file on any other version than Russian.
 
Upvote 0
I do not know that opening an already created workbook in another version will change any names. I would suspect not.

That said, whilst prefacing the procedure name with the module name is fine, the issue that I would suggest looking at is where the called procedure is. That is, it is just simply easier to keep a procedure called by .Run, .OnAction or .OnTime housed in a Standard Module. Move MESSAGE1() to a Standard Module and you should have no issues :-)

Hope that helps,

Mark
 
Upvote 0
I thing I tried that before with no luck, but after your advice I tried it again and it worked ) Thank you!
 
Upvote 0
Dear Mark, I would also be grateful if you could say how I can in this macro stop all previous Application.OnTime. I mean reset timer first every time on event Workbook_SheetSelectionChange.
I'm reading this now in different places in the Internet but I'm becoming more and more confused.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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