VBA A simple second Timer

Last update on December 5, 2008 01:24 PM by netty5
Published by netty5

VBA A simple second Timer








In VBA, there is Timer feature available,but you can create one very easily.

In a module sheet:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'For example: Start / Stop the timer every time the cell. 
'but may also be placed on a button or another ... 
   TimeOnOFF = Not TimeOnOFF
    If TimeOnOFF Then Timer
End Sub



In a public module:

Public TimeOnOFF As Boolean

Sub Timer()
Dim S As Integer
    While TimeOnOFF = True
        If Second(Now) > S Or Second(Now) = 0 Then
            '  Run code
            '....
            'for example
            Sheets("shee1").Range("A1").Value = Time
            
            S = Second(Now)
        End If
        DoEvents
    Wend
    
End Sub
Best answers for « VBA A simple second Timer » in :
Windows Timer Shutdown Show Windows Timer Shutdown This tip will help you manage your computer time usage. Useful, if you are a parent and you want your children to use the computer moderately! The process is very simple, Windows XP has a built-in mode to turn off...
VBA: How to know everything about the file folder ShowVBA: How to know everything about the file folder Preliminaries In module In sheet1 module Preliminaries Open a new workbook Add a module In module ' Declare variables for wizard. Public balloon1 As Balloon Public balloon2...
[VBA] Detecting changes in cell Show[VBA] Detecting changes in cell The Event Change feature of a sheet will detects the change in the active cell but it gives no information about the content. The example given below will help you to find out if the cell was changed,...
[VBA/VB6] My Documents + Environment Variables Show[VBA/VB6] My Documents + Environment Variables With VBA With VB6 Environment Functions Windows Variables Getting started As displayed in Windows Explorer, the My Documents folder appears to be in the root, but it is not the case. It...
Download Vista Shutdown Timer ShowWhen you download a spacious file or when an installation or a transfer hesitates to end! Not how to be obliged to wait for the end of task? Vista Shut Down Timer is a program allowing to define the hour of stopping or the conditions of stopping of...
Download Second Backup ShowSecond Backup is a tool for data backup. It can automatically backup your data on your hard disk, USB disk, network and other storage media. Advantage You simply define what file or folder backup, where and when to copy. It works reliably in...
HTML document layout ShowHTML document An HTML page is a simple file containing text formatted with HTML tags. Traditionally, the file is given an .htm or .html extension, but a web page may have other extensions as well. A web page can be built from even the most basic...