How to Create a Timer with Milliseconds in Excel VBA

Get FREE Advanced Excel Exercises with Solutions!

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.

What is ExcelDemy?

ExcelDemy Learn Excel & Excel Solutions Center provides free Excel tutorials, free support , online Excel training and Excel consultancy services for Excel professionals and businesses. Feel free to contact us with your Excel problems.

Tags:

Wasim Akram

Wasim Akram, BSc, Industrial and Production Engineering, Ahsanullah University of Science & Technology, has been working with the ExcelDemy project for 10 months. Currently working as as Excel and VBA content developer who provides authentic solutions to different Excel-related problems and writes amazing content articles regularly. He published almost 150 articles and has many more coming. He is very passionate about learning new things about Microsoft office Suite and Data analysis.

We will be happy to hear your thoughts

Advanced Excel Exercises with Solutions PDF