Calculate Seconds Between two Times in Excel VBA Calculate seconds Between two Times in Excel VBA

Calculate seconds Between two Times in Excel VBA using VBA formulas. We use DateDiff VBA Function to determine the number of seconds between two Times. In order to calculate number of seconds between two Times we need start time and end time. It returns an integer value as a result.

Macro to Calculate Number of seconds Between two Times in Excel VBA

Let us see the macro to count number of seconds Difference Between two Times in Excel VBA.

```'Calculate seconds Between two Times in Excel VBA
Sub VBA_Calculate_seconds_Between_Two_Times()

'Variable declaration
Dim sTime As Date, eTime As Date
Dim iValue As Integer

'Start Time
sTime = "10:10:10"

'End Time
eTime = "10:10:50"

iValue = DateDiff("s", sTime, eTime)

'Display output on the screen
MsgBox "The number of seconds between two Times : " & iValue, vbInformation, "Seconds Between Two Times"

End Sub
```

Here is the output screen shot of above macro. Instructions to use Macro

Here are the instructions to use above macro in Visual basic editor.

• Open Visual Basic Editor(VBE) by clicking Alt +F11
• Go to code window by clicking F7
• Copy above specified macro or procedure
• Paste above copied code in code window
• Run macro by clicking F5 or Run command
• You can see output on the screen
• Find above specified output screenshot.