VBA TimeSerial function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

TimeSerial Function Description

The VBA TimeSerial function returns a time variable based on the provided hour, minute, and second values.

Syntax

The syntax for the TimeSerial function in VBA is:

TimeSerial( hour, minute, second )

Parameters

hour
A numeric value representing the hour value of the time.

minute
A numeric value representing the minute value of the time. This can be also below 0 and above 59 values.

second
A numeric value representing the second value of the time. This can be also below 0 and above 59 values.

Other Notes

Providing negative or values above 59 for minutes or seconds is possible for the TimeSerial function. Providing negative values will subtract the amount of hours / seconds from the provided time. Providing values above 59 will increment appropriately the provided time.

Example usage

The TimeSerial function can be used in VBA code. Let’s look at some VBA TimeSerial function examples:

TimeSerial 15, 10, 15 
'Result: 3:10:15

TimeSerial 8, 20, 59
'Result: 8:20:59

TimeSerial 10, -10, 50
'Result: 9:50:50

TimeSerial 10, -10, -10
'Result: 9:49:50

Simply the best place to learn Excel VBA