compare two times - is it correct or actually how?

earp_

Active Member
Joined
Apr 30, 2008
Messages
305
Hi
I have a cell with a timestamp in this format
this cell updates itself dynamically and it is in Sheet1 E1
and I declared this
Application.OnTime TimeValue("11:00:00"), "mySub"
so I will start from 11, and if I'm not wrong with
I have the current time.

So if I want do something for example every 20 mins from 11:00 to 20:00 I can write different IFs

If (Now = 11:20) Then
..
EndIf
If (Now = 11.40) Then
..
EndIf

If (Now = 12:00) Then....
...

My questions is:
is that syntax correct?
is there a cleverest way?

thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
it explains about
"Scheduling Events With OnTime And Windows Timers"
but I don't want windows time.
I want to know if it is possible to compare two times.
 
Upvote 0
I thought you wanted to run your procedure every 20 minutes. Chip shows you how to run a procedure every 2 minutes, so just change the value of the constant cRunIntervalSeconds to suit.
 
Upvote 0

Forum statistics

Threads
1,213,536
Messages
6,114,205
Members
448,554
Latest member
Gleisner2

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