Refesh time

L

Lorri

Is there anyway to have an excel file up and have it automatically refresh
the file so that the time gets updated every minute?
Thanks
Lorri
 
B

Bob Phillips

Add this procedures

Public nTime as double

Public Sub ShowTime()
Worksheets("Sheet1").Range("A1").Value = Format(Time, "hh:mm:ss")
nTime = Now + TimeSerial(0, 0, 1)
Application.OnTime nTime, "ShowTime"
End Sub

and run it.

You need to stop it also

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnTime ntime, "ShowTime", , False
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code
--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
L

Lorri

Thanks - So I just enter this in - go back to the file and it should
automatically refresh the file every minute to update the time while I have
the file open?
 
B

Bob Phillips

Not quite, you will need to launch it, Tools>Macro>Macros..., select
ShowTime and run it.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
L

Lorri

So there is no way to have the file up - like a schedule and have it update
the time every minute to do a conditional format?

I apprecaite the feedback
 
B

Bob Phillips

Yeah, add a workbook open procedure


Private Sub Workbook_Open()
ShowTime
End Sub

'This is workbook event code.
'To input this code, right click on the Excel icon on the worksheet
'(or next to the File menu if you maximise your workbooks),
'select View Code from the menu, and paste the code


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
L

Lorri

Thanks Bob- I am having issues though - How do I get this to run? I can input
it fine but it is not updating anything. I follow the instructions you gave
me and then just X out of the screen to go back to the file, but then what?
Am I missing something?
 
B

Bob Phillips

Then save the workbook, close it and open it again, it should all start.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Top