VBA TimeValue Function
In this Article
TimeValue Description
Returns the serial number of a time.
Simple TimeValue Examples
Here is a simple TimeValue example:
1 2 3 |
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
1 |
MsgBox TimeValue("6:30") |
Result: 6:30:00 AM
1 |
MsgBox TimeValue("6:30 PM") |
Result: 6:30:00 PM
1 |
MsgBox TimeValue("16:30:15") |
Result: 4:30:15 PM
VBA Coding Made Easy
Stop searching for VBA code online. Learn more about AutoMacro - A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!
Learn More!