• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

system time run automatically when open file.

JAMIR

Member
Hi,
I have module in my wrkbook for running system time. The code as follows.

Code:
Global clockOn As Boolean
Sub runClock()
Range("GatePass!L5").Value = Now()
If clockOn = True Then
Application.OnTime Now + TimeValue("00:00:01"), "runClock"
End If
End Sub

Sub startClock()
clockOn = True
runClock
End Sub

Sub stopClock()
clockOn = False
End Sub

But for Starting the Clock I have create Button for it. I just want to run the clock when open my workbook. How it will be work?

Regards,

Zameer
 
Last edited by a moderator:
Add the following to the ThisWorkbook module in your Excel file

Code:
Private Sub Workbook_Open()
  Call runClock
End Sub
 
Hello Hui Sir,

I am feeling very greatful with your reply. Your above code i have add in my ThisWorkbook module. But i have already added one code for specific sheet open when open the file.

Private Sub Workbook_Open()
Worksheets("SoftTitle").Activate - "For desire sheet open."
End Sub

When i add above code it gave compile error. [Ambigous name detected Workbook_Open]

What should i do?

Regards,

Zameer
 
Hi Zameer ,

Since the code for what happens when you click the button is :

clockOn = True
runClock

just include the above two lines in your existing Workbook_Open macro ; you cannot have two macros named Workbook_Open.

Narayan
 
Back
Top