+ Reply to Thread
Results 1 to 6 of 6

Clock or counter function in excel?

  1. #1
    Registered User
    Join Date
    11-08-2007
    Posts
    22

    Clock or counter function in excel?

    Hi,

    Is there a counter or clock function in excel?
    I want to count time in a cell when another cell gets a certain value...is that possible?

    Your help is much appretiaced, thanks!

    ,KiBBo

  2. #2
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    put this code into the Worksheets VBE object. Change A1 witht he cell that you want to verify and the offset should reference the cell that you want the time input to. Also, change the IF condition of Target = 5 to whatever condition you are checking for.

    Please Login or Register  to view this content.
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

  3. #3
    Registered User
    Join Date
    11-08-2007
    Posts
    22

    Re:

    Thanks for you reply Excelenator!

    I think I explained myself badly...I really need a "timer" or calculator which counts seconds when I trigger it with certain value in certain cell. With "Now" function the value (actual time) is always refreshed and I don't now anymore when count started....any other suggestions or advices how I can use that "Now"- function?

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    In the code module for the sheet:
    Please Login or Register  to view this content.
    In a normal module:
    Please Login or Register  to view this content.
    put =timeInterval() in a cell and it will start counting as soon as the contents of A1 are 2 or greater. That cell will refresh its value whenever you change the selection. Setting A1 to 0 will reinitialize the timer.

    The cell location and trigger values to match your needs would go in the Worksheet_Change routine.

    Edit: Change in routine to prevent crashing when text is in A1.
    Last edited by mikerickson; 11-12-2007 at 03:59 PM.

  5. #5
    Forum Contributor
    Join Date
    12-12-2006
    Location
    New Zealand
    Posts
    151
    You can use ontime.

    Place this code in a module:

    Please Login or Register  to view this content.
    Put this under the sheet module:

    Please Login or Register  to view this content.
    And this in the thisworkbook module:

    Please Login or Register  to view this content.
    When ever the value in cell a1 gets above 1 the timer will start in B1. It will only stop and reset when the cell goes below 1.

    You could also use a start/stop button if you like.

    Format cell B1 as custom format "hh:mm:ss"

    See attached for further help.
    Attached Files Attached Files
    Last edited by Reafidy; 11-12-2007 at 05:19 PM.
    Reafidy.

    Tip: When using code and disabling events/screen updates/calculation be sure to use an error handler to turn them back on if an error occurs.

  6. #6
    Registered User
    Join Date
    11-08-2007
    Posts
    22

    Smile RE: Thanks!!! Problem solved

    ...solved with your help, thanks to everybody!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1