Excel VBA Second Function

Excel VBA Second Function: The Second function in VBA returns the second element for the specified time. 

Syntax

Second (Time)

Parameter

Time (required) – This parameter represents the time.

Return

This function returns the second element for the specified time. 

Example 1

Sub SecondFunction_Example1()
 ' returns the current time
 Dim second_val As Single
 Const time_val = "17:26:53"
 second_val = Second(time_val)
 ' The variable second_val will return 53
 Cells(1, 1).Value = second_val
 End Sub 

Output

53

VBA Second Function

Example 2

Sub SecondFunction_Example2()
 ' returns the current second
 Dim second_val As Single
 time_val = Time()
 second_val = Second(time_val)
 ' The variable second_val will return 27
 Cells(1, 1).Value = second_val
 End Sub 

Output

27

VBA Second Function