A Timer question

SpHawk

New Member
Joined
Sep 19, 2009
Messages
13
I have a sheet in which numbers keep being added to a cell until it reaches a set number. Say 1, every 3 minutes until it reaches 7.

Alternately the time may need to be set to 5 minutes or 7 minutes. And the number it totals at may change.

I read the timers that were put up, and none of them seem to be adding numbers to cells, so I thought I'd ask for help. :eek:

I was going to set the first variable in one cell, and then in another cell use an if statement to start the timer when the number dropped below the first until it returned to the right total, that being the amount of time needed.

Is there a way of doing a while / wend in excel? I could start the time manually, but wondered what could be done.

Thanks in advance,
Bob
 

RolfJ

Banned
Joined
Jul 29, 2009
Messages
333
I am not sure whether I correctly understood all your requirements, but this code might get you started in the right direction, assuming that you have the parameters for the conditions you would like to work with in the cells specified in the constant declarations at the top of the code:

Code:
Const CELL_COUNTER = "C22"
Const CELL_MAX_AMOUNT = "C23"
Const CELL_INCREMENT = "C24"
Const CELL_CHECK_TIME = "C25"
 
Sub IncrementCounter()
    Dim currentTime As Date
    Dim counter As Long
    counter = Range(CELL_COUNTER).Value
    Dim maxAmount As Long
    maxAmount = Range(CELL_MAX_AMOUNT).Value
    Dim increment As Long
    increment = Range(CELL_INCREMENT).Value
    Dim checkTime As Double
    checkTime = Range(CELL_CHECK_TIME).Value
    currentTime = Now()
    While counter < maxAmount
        DoEvents
        If Now() >= currentTime + TimeValue("00:" & checkTime & ":00") Then
            counter = counter + 1
            Range(CELL_COUNTER) = counter
            currentTime = currentTime + TimeValue("00:" & checkTime & ":00")
        End If
    Wend
End Sub
Hope this helped,
Rolf Jaeger
SoarentComputing
http://soarentcomputing.com

Phone: 800.580.0068
Cell: 510.300.7462
 

SpHawk

New Member
Joined
Sep 19, 2009
Messages
13
I'm sorry I wasn't clear, but thank you for the help.

I have 5 kids. Math program. There will be tasks to do when the number drops. And a timer that will give you time to do it. 3min for hard, 4 min for medium and 5 for easy. Everytime you get a problem right, the number drops again, giving you more time to complete the sheet.

I was just trying to get a timer to add 1 pt to a cell until it reached it's max. (The number of problems x2) It would be great if the timer started on its' own, but really isn't important. Just a sheet I started writing to keep my younger kids interested, and maybe challenge the 2 oldest. Going to make a game of it, and all that.

Thank you for your help,
Bob
 

Forum statistics

Threads
1,082,644
Messages
5,366,728
Members
400,917
Latest member
BlueBeerR

Some videos you may like

This Week's Hot Topics

Top