Simple time difference

itsupport

New Member
Joined
Aug 14, 2003
Messages
25
Hi

Maybe a simple request but i just need direction.

I have a sheet that users enter a reference number and the time that they contacted a user.
I also have a "now" field with the current time.
Our users need to make contact with theses other user on the hour so need an alarm to remind them when to do this.
I basically need the "now" cell to look at the recorded time and it its over an hour to pop a single word in a cell next to it stating "Escalate"
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hi,

This will only work IF the worksheet is being updated. =NOW() will not change unless the worksheet has changed.


Excel Workbook
ABCDE
1ReferenceContact TimeStatusNowTime Period
2AK123416:50:00ESCALATE18:35:3901:00:00
3Ak123517:45:00***
4AK123618:00:00***
5AK123717:34:00ESCALATE**
Sheet1


You would need some VBA code to continuously update the time in D2.
I don't write or understand VBA, so I cannot help you with the following code, sorry. I have taken it from a workbook I have as it is.

Press alt F11, click on This Workbook and paste the following code into the white area..

Code:
Dim bolOpening As Boolean
Dim t As Date
Private Sub Workbook_Open()

Flag = True
    RunWhen = Now + TimeSerial(0, 0, 1)
    Application.OnTime RunWhen, "UpdateClock"

t = Now

End Sub


Private Sub Workbook_BeforeClose(Cancel As Boolean)
 
    Flag = False
    Call StopClock

End Sub


This needs to be put into a Module, whilst still in the VBA window, click on Insert click Module and paste this code into the white area...


Code:
Public Flag As Boolean
Public RunWhen As Double
Sub UpdateClock()
    If Flag = True Then
'       *** Change Sheet name and Range reference to suit ***
        Worksheets("Sheet1").Range("D2").Calculate
        RunWhen = RunWhen + TimeSerial(0, 0, 1)
        Application.OnTime RunWhen, "UpdateClock"
    End If
End Sub


Sub StopClock()
    On Error Resume Next
    Application.OnTime EarliestTime:=RunWhen, Procedure:="UpdateClock", Schedule:=False
End Sub

I hope that you find this helpful, good luck.

Ak
 
Upvote 0

Forum statistics

Threads
1,224,568
Messages
6,179,595
Members
452,927
Latest member
whitfieldcraig

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