Results 1 to 3 of 3

Clock not working properly

Threaded View

  1. #1
    Registered User
    Join Date
    09-15-2016
    Location
    Malaysia
    MS-Off Ver
    Windows 7
    Posts
    5

    Clock not working properly

    Currently I am using the following VBA programme.

    Initially this programme will work fine for the first 1 or 2 hrs. The clock will stop at the 10th seconds and the 11th seconds will continue in the following row. After 1 or 2 hrs, the clock will stop in either 11th or 12th seconds. The error will continue and multiply and may end up 1 or 2hrs different from what I require. I require the clock to stop at every 10th second exactly everytime without any interruption or error for 32hrs. I notice that this programme is very volatile and sometimes simply stop or even shutdown the excel and the entire computer automatically while in process. I am Microsoft Excel 2007/2010/2013 XML. I hope someone will help me to solve this problem. I need to solve this problem very quickly. Thanking in advance.


    Dim Seconds As Integer
    Dim Minutes As Integer
    Dim CurrentRow As Integer
    Dim CurrentColumn As Integer
    Dim Initalised As Boolean
    
    
    Private Sub Recalc()
          If (CurrentRow <> 0 And CurrentColumn <> 0) Then
              Cells(CurrentRow, CurrentColumn).Value = Format(Now, "dd/mm/yyyy")
              Cells(CurrentRow, CurrentColumn + 1).Value = Format(Time, "hh:mm:ss AM/PM")
    
              Seconds = Seconds + 1
    
                If (Seconds = 10) Then
                    Minutes = Minutes + 1
                    CurrentRow = CurrentRow + 1
                    Seconds = 0
               End If
    
               ' Stop repeating after 32 hours (1920 minutes)
               If (Minutes < 1920) Then
                   Call SetTime
                   Else
                   Initalised = False
               End If
        End If
    End Sub
    
    
    Sub SetTime()
          If (Not Initalised) Then
               Initalised = True
    
               ' Initialise variables.
               Seconds = 0
               Minutes = 0
               CurrentRow = ActiveCell.Row
               CurrentColumn = ActiveCell.Column
        End If
    
    
         SchedRecalc = Now + TimeValue("00:00:01")
         Application.OnTime SchedRecalc, "Recalc"
    End Sub
    Last edited by gurunathblessings; 09-15-2016 at 10:30 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Calculating Allocated Hours Based On Clock In and Clock Out
    By rahul_ferns76 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 05-15-2016, 07:46 AM
  2. Checking if my clock in my spreadsheet is working using VBA
    By Roadhouse in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-08-2015, 08:11 AM
  3. Replies: 2
    Last Post: 05-15-2014, 09:04 AM
  4. [SOLVED] IF-THEN-ELSE not working properly
    By danex in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-02-2013, 11:15 AM
  5. VBA not working properly
    By stevemills04 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-26-2013, 02:56 PM
  6. UDF not working properly
    By demuro1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-09-2008, 04:36 PM
  7. [SOLVED] How do I create a working clock in Excel 2000?
    By gmcmil1 in forum Excel General
    Replies: 0
    Last Post: 07-18-2005, 04:05 PM

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