TIMEVALUE Function – Text to Time in Excel, VBA, G Sheets
Written by
Reviewed by
Download the example workbook
This tutorial demonstrates how to use the TIMEVALUE Function in Excel to convert a time stored as text into a valid time.
TIMEVALUE Examples
Convert Time Stored as Text to Time
When working in spreadsheets you might encounter time stored as text. You can usually identify times stored as text because the times are left-aligned and are proceeded by apostrophes:
These “times” are treated as text and you’ll be unable to work with them like normal times.
One way to convert the text to a date is with the TIMEVALUE Function:
=TIMEVALUE(B3)
Things to know about the TIMEVALUE Function:
- TIMEVALUE ignores date information. To convert a date + time stored as text to a number, use the VALUE Function instead. Or use the DATEVALUE function to get the date only.
TIMEVALUE in Google Sheets
The TIMEVALUE Function works exactly the same in Google Sheets as in Excel:
TIMEVALUE Examples in VBA
You can also use the TIMEVALUE function in VBA. Type:
application.worksheetfunction.timevalue(time_text)
Running the following VBA statements
Range("B2") = TimeValue(Range("A2"))
Range("B3") = TimeValue(Range("A3"))
will create the following output
For the function arguments (time_text, etc.), you can either enter them directly into the function, or define variables to use instead.