Calculations with one-thousandth fractions of seconds by Custom Function using VBA
Tags: calculationswithonet, vbamacros
Published: 2021-10-01 11:41:36

---
title: Calculations with one-thousandth fractions of seconds by Custom Function using VBA
published: true
date: 2021-09-30 08:12:29 UTC
tags: CalculationsWithOneT,VBAMacros
canonical_url: https://geekexcel.com/calculations-with-one-thousandth-fractions-of-seconds-by-custom-function-using-vba/
---

In this article, you will learn the simple steps for **calculations with one-thousandth fractions of seconds by custom function** using VBA. Let’s get them below!! Get an official version of MS Excel from the following link: **[https://www.microsoft.com/en-in/microsoft-365/excel](https://www.microsoft.com/en-in/microsoft-365/excel)**

## Syntax

```
=spectime(A1)
```

## Example

- Firstly, in the Excel Worksheet, you have to go to the  **Developer Tab.**
- Then, you need to ** ** select the  **Visual Basic**  option under the  **Code**  section.

![Select Visual Basic](https://geekexcel.com/wp-content/uploads/2021/09/Select-Visual-Basic-9-1024x180.png)<figcaption>Select Visual Basic</figcaption>

- Now, you have to  **copy and paste the code**  given below.

```
Function SpecTime(txt As String)
   Const DIV As Long = 86400
   Dim dblValue As Double
   dblValue = CInt(Right(txt, 4)) / (DIV * 10000)
   dblValue = dblValue + CInt(Mid(txt, 4, 2)) / DIV
   dblValue = dblValue + CInt(Left(txt, 2)) / (DIV / 60)
   SpecTime= dblValue
End Function

```

- You need to  **save the code**  by selecting it and then  **close the window**.

![](https://geekexcel.com/wp-content/uploads/2021/09/Save-the-Code-98.png)<figcaption>Save the Code</figcaption>

- Again, you have to go to the  **Excel Spreadsheet** , and click on the  **Developer Tab**.
- You need to choose the  **Macros option**  in the Code section.

![Choose Macro option](https://geekexcel.com/wp-content/uploads/2021/09/Choose-Macro-option-11-1024x184.png)<figcaption>Choose Macro option</figcaption>

- Now, you have to make sure that your  **macro name is selected**  and click the  **Run ** button.
- Finally, you will get **calculations with one-thousandth fractions of seconds** by custom function using VBA.

## Summary

We hope that this tutorial gives you guidelines on ** calculations**  **with one-thousandth fractions of seconds by custom function** using VBA. Please leave a comment in case of any  **queries,**  and don’t forget to mention your valuable  **suggestions**  as well. Thank you so much for Visiting Our Site!! Continue learning on **[Geek Excel](https://geekexcel.com/)!! **Read more on [**Excel Formulas**](https://geekexcel.com/excel-formula/) **!!**

**Keep Reading:**

- **[Excel Formulas: IF Function with Other Calculations!!](https://geekexcel.com/excel-formulas-if-function-with-other-calculations/)**
- **[Calculate Cell Values Based on Font, Background, or Conditional Color in Excel 365!!](https://geekexcel.com/calculate-cell-values-based-on-font-background-or-conditional-color-in-excel-365/)**
- **[Formulas to Find the Date & Time Calculations in Excel 365!!](https://geekexcel.com/formulas-to-find-the-date-time-calculations-in-excel-365/)**
- **[Excel Formulas to Convert Decimal Seconds into Excel Time!!](https://geekexcel.com/excel-formulas-to-convert-decimal-seconds-into-excel-time/)**
- **[Excel Formulas to Convert Excel Time into Decimal Seconds ~ Easy Tricks](https://geekexcel.com/excel-formulas-to-convert-excel-time-into-decimal-seconds/)**