Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Time Function

Are there other functions beside NOW() that I can use to have the correct time displayed in a cell ?
  #2   Report Post  
Senior Member
 
Posts: 663
Default

Quote:
Originally Posted by View Post
Are there other functions beside NOW() that I can use to have the correct time displayed in a cell ?
What's wrong with the NOW() function that means you need a different one?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Time Function

On Tuesday, September 11, 2012 3:36:34 PM UTC-4, (unknown) wrote:
Are there other functions beside NOW() that I can use to have the correct time displayed in a cell ?


For some reason it does not update all the time - there are pauses in the updates. So I'm looking for a time function that reflects the current time (hh:mm:ss) continuosly over the course of the day.
  #4   Report Post  
Junior Member
 
Location: Lakehurst, NJ, USA
Posts: 19
Default

Quote:
Originally Posted by View Post
On Tuesday, September 11, 2012 3:36:34 PM UTC-4, (unknown) wrote:
Are there other functions beside NOW() that I can use to have the correct time displayed in a cell ?


For some reason it does not update all the time - there are pauses in the updates. So I'm looking for a time function that reflects the current time (hh:mm:ss) continuosly over the course of the day.
To get a cell (say B9) to display an updating time, run the StartClock macro listed below:

Dim PleaseStopMe As Boolean

Sub StopIt()
PleaseStopMe = True
End Sub

Sub StartClock()
PleaseStopMe = False
Do
Range("B9").Value = Format(Now, "hh:mm:ss")
DoEvents
If PleaseStopMe Then Exit Sub
Loop
End Sub

To stop the clock, run the StopIt macro
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default Time Function

Hi all

I use this nice chunk of code which works very nicely, essentially this
saves the workbook to 2 locations ( 2 is a backup ), it also stamps ( C2
) with the time it was last saved so you have a visual reference of it.

If you want to trogger some other type of event, simply replace the
SaveBook routine, and or the timer frequency with your desired timeframe
in which to fire.


Put this in the "ThisWorkbook"

Private Sub Workbook_Open()
StartTimer
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
StopTimer
End Sub

Then in a Module, use this to start the timer, it is currently set to
trigger ever 30 minutes..

Option Explicit
Public RunTime

Sub StartTimer()

RunTime = Now + #12:30:00 AM#

Application.OnTime RunTime, "SaveBook", schedule:=True

End Sub



Sub SaveBook()

StartTimer

ChDir "C:\"
ActiveWorkbook.SaveAs Filename:= _
"C:\WowSchedMaster.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ChDir "T:\WOW VIC\wow scheduler"
ActiveWorkbook.SaveAs Filename:="T:\WOW VIC\wow
scheduler\WowSchedMaster.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

ActiveSheet.Select
Range("C2").Select
Selection.NumberFormat = "hh:mm"
Selection.Value = Now()

End Sub

And finally, this stops the timer...

Sub StopTimer()

On Error Resume Next
Application.OnTime RunTime, "SaveBook", schedule:=False

End Sub


HTH
Mick.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there an XLS function to convert std time to Military time? Carl Excel Worksheet Functions 1 May 20th 09 09:48 PM
Macro / function text time to 24hr excel time passed midnight fortotaling hr's Russmaz Excel Worksheet Functions 2 March 6th 09 04:58 AM
verify use of TIME Function, Find Quantity Level compare to time-d nastech Excel Discussion (Misc queries) 9 July 11th 07 01:58 PM
Function Call Specified at Run Time rather than Compile Time? Mac Lingo[_2_] Excel Programming 1 September 8th 05 04:20 PM
Function to convert Time String to Time Andibevan Excel Worksheet Functions 6 August 19th 05 01:19 PM


All times are GMT +1. The time now is 01:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"