System Time auto running in VBA Excel

Dave_LearningExcel

New Member
Joined
May 16, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,

May I request your help? I need a system time running in my excel and I use below code:
Private Sub workbook_Open()
Dim Hr As Boolean

Hr = Not (Hr)
Do While Hr = True
DoEvents
Range("E11") = TimeValue(Now)
Loop

End Sub

Would you please advise how to make this code auto running when I open my excel file?

Much appreciate your help. Thank you.

Best,
Dave
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You need to place the code within the ThisWorkbook section of the desired project within VBE.

1684307949795.png


However, this macro will never stop, so you won't be able to use the workbook while it's running, which is indefinitely.
 
Upvote 0

Forum statistics

Threads
1,215,872
Messages
6,127,428
Members
449,382
Latest member
DonnaRisso

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top