Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Excel function to update time every minute

Afternoon all,

Is it possible to create custom function that updates the time every minute?

I have the following code that will update the time:

Sub UpdateTime()
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"

End Sub
Sub TimeUp()
[a1] = Time
End Sub

But i have no idea how to wrap this (if it is even possible!) into a custom
function...

Thank you.

Richard


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel function to update time every minute

Private nextTime As Date

Sub UpdateTime()
nextTime = Now + TimeValue("00:00:02") ' << change to 00:01:00
Application.OnTime nextTime, "TimeUp"
End Sub

Sub TimeUp()
Static n As Long ' just for testing
n = n + 1
Cells(n, 1) = Time
UpdateTime
End Sub

Sub StopUpdate()
If nextTime Then
Application.OnTime nextTime, "TimeUp", , False
nextTime = 0
End If
End Sub

Sub auto_close()
' be sure to stop in a close event
StopUpdate

End Sub


Regards,
Peter T

"Richard Edwards" wrote in message
...
Afternoon all,

Is it possible to create custom function that updates the time every
minute?

I have the following code that will update the time:

Sub UpdateTime()
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"

End Sub
Sub TimeUp()
[a1] = Time
End Sub

But i have no idea how to wrap this (if it is even possible!) into a
custom function...

Thank you.

Richard



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Excel function to update time every minute

thanks for that but it will not be available as a custom function...?


"Peter T" <peter_t@discussions wrote in message
...
Private nextTime As Date

Sub UpdateTime()
nextTime = Now + TimeValue("00:00:02") ' << change to 00:01:00
Application.OnTime nextTime, "TimeUp"
End Sub

Sub TimeUp()
Static n As Long ' just for testing
n = n + 1
Cells(n, 1) = Time
UpdateTime
End Sub

Sub StopUpdate()
If nextTime Then
Application.OnTime nextTime, "TimeUp", , False
nextTime = 0
End If
End Sub

Sub auto_close()
' be sure to stop in a close event
StopUpdate

End Sub


Regards,
Peter T

"Richard Edwards" wrote in message
...
Afternoon all,

Is it possible to create custom function that updates the time every
minute?

I have the following code that will update the time:

Sub UpdateTime()
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"

End Sub
Sub TimeUp()
[a1] = Time
End Sub

But i have no idea how to wrap this (if it is even possible!) into a
custom function...

Thank you.

Richard





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel function to update time every minute

What do you mean by a custom function, what do you want it to return, what's
the objective.

Regards,
Peter T

"Richard Edwards" wrote in message
...
thanks for that but it will not be available as a custom function...?


"Peter T" <peter_t@discussions wrote in message
...
Private nextTime As Date

Sub UpdateTime()
nextTime = Now + TimeValue("00:00:02") ' << change to 00:01:00
Application.OnTime nextTime, "TimeUp"
End Sub

Sub TimeUp()
Static n As Long ' just for testing
n = n + 1
Cells(n, 1) = Time
UpdateTime
End Sub

Sub StopUpdate()
If nextTime Then
Application.OnTime nextTime, "TimeUp", , False
nextTime = 0
End If
End Sub

Sub auto_close()
' be sure to stop in a close event
StopUpdate

End Sub


Regards,
Peter T

"Richard Edwards" wrote in message
...
Afternoon all,

Is it possible to create custom function that updates the time every
minute?

I have the following code that will update the time:

Sub UpdateTime()
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"

End Sub
Sub TimeUp()
[a1] = Time
End Sub

But i have no idea how to wrap this (if it is even possible!) into a
custom function...

Thank you.

Richard







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Excel function to update time every minute

sorry - user defined function....so i can put a cell =customtime() and it
will update the time once a minute.

"Peter T" <peter_t@discussions wrote in message
...
What do you mean by a custom function, what do you want it to return,
what's the objective.

Regards,
Peter T

"Richard Edwards" wrote in message
...
thanks for that but it will not be available as a custom function...?


"Peter T" <peter_t@discussions wrote in message
...
Private nextTime As Date

Sub UpdateTime()
nextTime = Now + TimeValue("00:00:02") ' << change to 00:01:00
Application.OnTime nextTime, "TimeUp"
End Sub

Sub TimeUp()
Static n As Long ' just for testing
n = n + 1
Cells(n, 1) = Time
UpdateTime
End Sub

Sub StopUpdate()
If nextTime Then
Application.OnTime nextTime, "TimeUp", , False
nextTime = 0
End If
End Sub

Sub auto_close()
' be sure to stop in a close event
StopUpdate

End Sub


Regards,
Peter T

"Richard Edwards" wrote in message
...
Afternoon all,

Is it possible to create custom function that updates the time every
minute?

I have the following code that will update the time:

Sub UpdateTime()
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"

End Sub
Sub TimeUp()
[a1] = Time
End Sub

But i have no idea how to wrap this (if it is even possible!) into a
custom function...

Thank you.

Richard











  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel function to update time every minute

A UDF can only return a value, it cannot do or invoke anything that will
change the interface, such as writing a value to some other cell, or "update
itself later" (albeit there are some trick type workarounds).

For your needs why not assign a macro to a button (you could trap and store
the activecell as the cell that will receive the future updates).
Alternatively you could start/stop updates in sheet and/or workbook
activate/deactivate events. For either approach, adapt the code I posted
previously.

Regards,
Peter T



"Richard Edwards" wrote in message
...
sorry - user defined function....so i can put a cell =customtime() and it
will update the time once a minute.

"Peter T" <peter_t@discussions wrote in message
...
What do you mean by a custom function, what do you want it to return,
what's the objective.

Regards,
Peter T

"Richard Edwards" wrote in message
...
thanks for that but it will not be available as a custom function...?


"Peter T" <peter_t@discussions wrote in message
...
Private nextTime As Date

Sub UpdateTime()
nextTime = Now + TimeValue("00:00:02") ' << change to 00:01:00
Application.OnTime nextTime, "TimeUp"
End Sub

Sub TimeUp()
Static n As Long ' just for testing
n = n + 1
Cells(n, 1) = Time
UpdateTime
End Sub

Sub StopUpdate()
If nextTime Then
Application.OnTime nextTime, "TimeUp", , False
nextTime = 0
End If
End Sub

Sub auto_close()
' be sure to stop in a close event
StopUpdate

End Sub


Regards,
Peter T

"Richard Edwards" wrote in message
...
Afternoon all,

Is it possible to create custom function that updates the time every
minute?

I have the following code that will update the time:

Sub UpdateTime()
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"

End Sub
Sub TimeUp()
[a1] = Time
End Sub

But i have no idea how to wrap this (if it is even possible!) into a
custom function...

Thank you.

Richard











  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Excel function to update time every minute

ok. thanks for your help.

rich

"Richard Edwards" wrote in message
...
Afternoon all,

Is it possible to create custom function that updates the time every
minute?

I have the following code that will update the time:

Sub UpdateTime()
Application.OnTime Now + TimeValue("00:01:00"), "TimeUp"

End Sub
Sub TimeUp()
[a1] = Time
End Sub

But i have no idea how to wrap this (if it is even possible!) into a
custom function...

Thank you.

Richard



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
Time and Minute formulas Prem Soni Excel Programming 2 July 23rd 08 12:00 PM
HELP! time on a 45 minute Agenda Excel ??[_2_] Excel Discussion (Misc queries) 7 January 25th 08 10:20 PM
How do I get time elapsed in terms of minute? Mcspore Excel Discussion (Misc queries) 9 December 10th 07 05:40 PM
Using time formats in minute units josh Excel Discussion (Misc queries) 4 September 11th 05 10:19 PM
convert time from 60 minute hour to 100 minute hour Jboerding Excel Discussion (Misc queries) 2 July 6th 05 11:30 PM


All times are GMT +1. The time now is 08:21 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"