Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default Keep Timer Going While Altering Workbook

I am using the VB Timer function to feed a countdown timer (displayed in a
cell) and want to be able to edit my Workbook w/o stopping the timer. I've
tried using DoEvents in a Do loop but as soon as I edit a cell the timer
stops and I have to restart the macro to restart the timer. Is there a way
around this?

Thanks,
Will
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default Keep Timer Going While Altering Workbook

Will,

Maybe you can use the OnTime function. Something like this:

1. Create a new workbook.
2. Add a new module in the VB project and paste the code below.
3. Run the StartTimer procedure. It should start a 30 second timer and put
the remaining seconds in cell A1 of Sheet1.

One problem is that it stops updating while on edit mode.



Option Explicit
Private dTimerEnd As Date

Sub StartTimer()
Dim iSeconds As Integer

iSeconds = 30

dTimerEnd = Now + TimeSerial(0, 0, iSeconds)
Worksheets("Sheet1").Range("A1").Value = iSeconds

Application.OnTime EarliestTime:=Now + TimeValue("00:00:1"), _
procedu="CountDown"
End Sub

Sub CountDown()
Dim iSecondsLeft As Integer

iSecondsLeft = CInt((dTimerEnd - Now) * 86400)

If iSecondsLeft <= 0 Then iSecondsLeft = 0

Worksheets("Sheet1").Range("A1").Value = iSecondsLeft

If iSecondsLeft 0 Then
'keep going
Application.OnTime EarliestTime:=Now + TimeValue("00:00:1"), _
procedu="CountDown"
End If
End Sub



--
Hope that helps.

Vergel Adriano


"roadkill" wrote:

I am using the VB Timer function to feed a countdown timer (displayed in a
cell) and want to be able to edit my Workbook w/o stopping the timer. I've
tried using DoEvents in a Do loop but as soon as I edit a cell the timer
stops and I have to restart the macro to restart the timer. Is there a way
around this?

Thanks,
Will

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
Help with altering a formula cherman Excel Worksheet Functions 3 February 25th 10 09:18 PM
Way to insert a footer in an entire workbook w/o altering headers Deb Excel Discussion (Misc queries) 2 April 7th 09 09:13 PM
copy without altering the value freebee Excel Discussion (Misc queries) 4 October 31st 08 06:09 AM
Timer to close workbook when no activity detected swedbera Excel Programming 7 June 26th 06 09:22 PM
Stopping a Timer / Running a timer simultaneously on Excel Paul23 Excel Discussion (Misc queries) 1 March 10th 06 12:08 PM


All times are GMT +1. The time now is 07:23 AM.

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

About Us

"It's about Microsoft Excel"