How to Create a Timer with Milliseconds in Excel VBA

While working in Microsoft Excel sometimes we need to create a timer with milliseconds. You can easily do it using VBA in Excel. But sometimes it becomes difficult while create a timer. Today in this article, I am sharing with you how to create a timer with milliseconds in Excel VBA.

Steps-by-Step Procedures to Create a Timer with Milliseconds in Excel VBA

In the following, I have explained the step-by-step procedures to create a timer with milliseconds in Excel VBA. To do the task, we will apply VBA code with multiple VBA functions, such as the Format and Timer functions. Later on, we will assign a macro button to show the time in milliseconds.

Step 1: Creating Data Set with Timers

Above all, letâ€™s start with creating a dataset. We will put some time inside the worksheet.

• Just open a workbook and put your desired time in, just like the screenshot below.

Read More: Excel VBA to Create Timer Loop

Step 2: Applying VBA Code to Convert Time in Milliseconds

In this section, we will write VBA code and save it for further processing.

• Second, we will apply VBA code to convert time into milliseconds.
• Simply, select cells (B5:B12) and click ALT+F11 to open Microsoft Visual Basic for Applications.

• Next, 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``````

Step 3: Creating and Assigning a Macro Button

As we have saved our VBA code in the previous step, itâ€™s time for creating a macro button for the code and assigning according to it.

• In this step, we will create and assign a macro button for the code. To do so, choose a Rectangle Shape from the Insert option.

• Then, double-click on the worksheet to create the shape.

• Thereafter, type Timer MillisecondsÂ inside the box.

• Hence, selecting the shape right click to get multiple options. From the options choose Assign Macro.

• After that, select Timer Milliseconds from the Macro NameÂ and press OK.

Read More: How to Delay Timer with VBA in Excel

Step 4: Generating Final Results

Finally, click the button and you will get your output with a milliseconds timer in your hands. Within a short time, we created a timer with milliseconds in Excel VBA.

Conclusion

In this article, I have tried to cover almost all the steps to create a timer with milliseconds in Excel VBA. Take a tour of the practice workbook and download the file to practice by yourself. I hope you find it helpful. Please inform us in the comment section about your experience. We, the ExceldemyÂ team, are always responsive to your queries. Stay tuned and keep learning.

Get FREE Advanced Excel Exercises with Solutions!

Tags:

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

Advanced Excel Exercises with Solutions PDF