VBA TimeValue Function
In this Article
TimeValue Description
Returns the serial number of a time.
Simple TimeValue Examples
Here is a simple TimeValue example:
Sub TimeValue_Example()
MsgBox TimeValue("6:30:10")
End Sub
This code will return 6:30:10 AM.
TimeValue Syntax
In the VBA Editor, you can type “TimeValue(” to see the syntax for the TimeValue Function:
The TimeSerial function contains an argument:
Time: A string of text representing a time (ex. “12:00:00 A.M”).
Examples of Excel VBA TimeValue Function
MsgBox TimeValue("6:30")
Result: 6:30:00 AM
MsgBox TimeValue("6:30 PM")
Result: 6:30:00 PM
MsgBox TimeValue("16:30:15")
Result: 4:30:15 PM