Hello Lokesh,
Here's some code that implements a timer. You didn't mention where you want the time displayed--this code does it in a cell, but it is just as easy to modify the code to display it in the Excel Status Bar, in a userform textbox, or in a drawing or shape object.
I implemented this assuming you would like a Start button but also to have a Stop button and a Reset button, and that you would like to be able to stop and restart the timer.
Code:
Dim StopTimer As Boolean
Dim SchdTime As Date
Dim Etime As Date
Const OneSec As Date = 1 / 86400#
Private Sub ResetBtn_Click()
StopTimer = True
Etime = 0
[B3].Value = "00:00:00"
End Sub
Private Sub StartBtn_Click()
StopTimer = False
SchdTime = Now()
[B3].Value = Format(Etime, "hh:mm:ss")
Application.OnTime SchdTime + OneSec, "Sheet1.NextTick"
End Sub
Private Sub StopBtn_Click()
StopTimer = True
Beep
End Sub
Sub NextTick()
If StopTimer Then
'Don't reschedule update
Else
[B3].Value = Format(Etime, "hh:mm:ss")
SchdTime = SchdTime + OneSec
Application.OnTime SchdTime, "Sheet1.NextTick"
Etime = Etime + OneSec
End If
End Sub
This code must be placed in the sheet's code module. To do this, right-click on the sheet's tab, select View Code, and paste this code into the Code pane. Note that I assumed the sheet is Sheet1 and you should edit this name (2 places in the code). This is the sheet's codename, not the tab name. The codename is the name that appears between the sheet icon and the tab name in parentheses in the Visual Basic Editor Project pane.
This code assumes you have a start commandbutton named StartBtn, a stop button named StopBtn, and a reset button named ResetBtn (only the start button is required if you don't have a need to stop or reset the timer). To name a button simply select it and type the new name in the Name box just above cell A1.
This code displays the timer time value in cell B3, but you can change this by editing the code (3 places).