How to Create a Timer with Milliseconds in Excel VBA

Step 1 – Creating a Data Set with Timers

  • Open a workbook and put your desired alert times, just like the screenshot below.

Read More: Excel VBA to Create Timer Loop


Step 2 – Applying VBA Code to Convert Time to Milliseconds

  • Select cells (B5:B12) and click Alt + F11 to open Microsoft Visual Basic for Applications.

  • Go to Insert and select Module.
  • Inside the Module, place the following code and click on Save.
Sub Timer_Milliseconds()
Selection.NumberFormatLocal = "h:mm:ss.000"
ActiveCell.Value = Format(Now, "h:mm:ss") & Right(Format(Timer, "0.000"), 4)
End Sub

Applying VBA Code to Create a Timer with Milliseconds in Excel VBA

Read More: How to Create a Countdown Timer in Excel VBA


Step 3 – Creating and Assigning a Macro Button

  • Choose a Rectangle Shape from the Insert option.

Creating and Assigning a Macro Button to Create a Timer with Milliseconds in Excel VBA

  • Double-click on the worksheet to create the shape.

Creating and Assigning a Macro Button to Create a Timer with Milliseconds in Excel VBA

  • Type Timer Milliseconds inside the box.

  • Right-click on the shape and choose Assign Macro.

Creating and Assigning a Macro Button to Create a Timer with Milliseconds in Excel VBA

  • Select Timer Milliseconds from the Macro Name and press OK.

Creating and Assigning a Macro Button to Create a Timer with Milliseconds in Excel VBA


Step 4 – Generating Final Results

  • Click the button and you will get your output with a millisecond timer.

excel vba timer milliseconds

Read More: How to Create Timer Event with VBA in Excel


Download the Practice Workbook

Get FREE Advanced Excel Exercises with Solutions!

Tags:

Wasim Akram
Wasim Akram

Wasim Akram holds a BSc degree in Industrial and Production Engineering from Ahsanullah University of Science and Technology. Over the past 2 years, he has been actively contributing to the ExcelDemy project, where he has authored more than 150 articles. Now, he is working as an Excel VBA and Content Developer. He likes learning new things about Microsoft Office, especially Excel VBA, Power Query, Data Analysis, and Excel Statistics. He is also very interested in machine learning and... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo