The VBA SECOND Function

Related Functions:
VBA Hour
VBA Minute

Description

The VBA Second Function returns the second component of a supplied time. The syntax of the function is:

Second( Time )

VBA Second Function Example

A simple example of the VBA Second function is shown below:

' Extract the second component from the time "17:56:33"
Const currTime = "17:56:33"
Dim secNum As Integer
secNum = Second(currTime)
' The variable secNum is now equal to 33.

After running the above VBA code, the variable secNum holds the value 33, which is the second component of the supplied time "17:56:33".


VBA Second Function Error

If the VBA Second function is supplied with a value that cannot be interpreted as a valid time, it will return the error:

Run-time error '13': Type mismatch

VBA Run Time Error 13 Message Box