VBA Function: TimeSerial
The VBA TimeSerial function returns a time based on an hour, minutes, and seconds.
Usage:
TimeSerial(hour, minutes, seconds)
Examples of Usage
Creating a time based on the 3 required arguments (hour, minutes, and seconds):
Sub example()
hourExample = 17
minutesExample = 34
secondsExample = 2
myTime = TimeSerial(hourExample, minutesExample, secondsExample)
MsgBox myTime 'Returns the time corresponding to 5:34:02 PM
End Sub
Creating the time 17:30 and adding it to cell A1:
Sub example()
Range("A1") = TimeSerial(17, 30, 0)
End Sub