Code to define dTime

albatross32

New Member
Joined
Feb 17, 2010
Messages
32
I want to use dTime to trigger a macro to refresh web sourced input data. The trigger time is to be linked to a timer in A1 and not 'Now'. Therefore, A1 contains a TimeValue and I want to define dTime so that my macro is triggered when A1 reaches "00:30:00".
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Thanks for your response but this does not answer my enquiry. I am looking to use a version of the following;


Code:
Public dTime As Date
Sub MyMacro()
dTime = Now + TimeValue("00:15:00")
Application.OnTime dTime, "MyMacro"
'YOUR CODE
End Sub</PRE>
</PRE>
Instead of using Now + TimeValue I want to say 'when the timer in A1 reaches 00:30:00 refresh input data'.</PRE>
 
Upvote 0
What timer in A1?

All you seem to have is a time value, unless you've got other code that's updating that.
 
Upvote 0
Please refer to my original enquiry. A1 contains a timer. It is being triggered by my external data source and is counting up from 00:00:00. I want to trigger a data input refresh when that timer reaches 00:30:00. I cannot use 'Now'.
 
Upvote 0
Your original post doesn't mention an external data source.

How does this time work?

Does is goto to 00:30:00 then back to 00:00:00?

Or is it at 00:30 intervals, eg 00:30:00, 01:00:00, 01:30:00?

How about setting dtimer to a have a small increment line 00:01:00?

When it's triggered check the value of A1 and continue with the code if required.
 
Upvote 0
The timer in A1 just keeps going until the workbook is closed. All I need is to trigger a single refresh of data once that timer reaches 00:30:00.
 
Upvote 0
Well try what I suggested.

Code:
Public dTime As Date
Sub MyMacro()

dTime = Now + TimeValue("00:01:00")

Application.OnTime dTime, "MyMacro"

If Range("A1").Value = TIMESERIAL(0,0,30) Then
      ' do whatever
End If
End Sub

How is the value in A1 triggered by the external data source anyway?

Perhaps it's not a timer you should use if you just want to trigger code when a cell has a certain value.
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,289
Members
452,902
Latest member
Knuddeluff

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