In the VBA, a simple second timer is easy to write and include in the source code. The VBA comes with a full-featured timer which can be used whenever required. However, it is not compulsory to use this timer already provided. Timer control in the VBA can be done through a manual timer too.With the VBA, a simple second timer can be created to enhance and customise the Office software especially for Excel worksheets. One needs to write the code to create a timer in a public module.
Create a Timer in VBA
In VBA there is Timer feature available, but you can also create one very easily. Follow these steps to do so:
In a module sheet:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
In a public module:
'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
Public TimeOnOFF As Boolean
Image © Alexey Malkin - 123rf.com
Dim S As Integer
While TimeOnOFF = True
If Second(Now) > S Or Second(Now) = 0 Then
' Run code
Sheets("shee1").Range("A1").Value = Time
S = Second(Now)