VBA TIMEVALUE Function (Syntax + Example)


- Written by Puneet (Last Updated: June 22, 2023)

The VBA TIMEVALUE function is listed under the time category of VBA functions. When you use it in a VBA code, it returns a valid time value from the string which represents the date and time or time. In simple words, with TIMEVALUE, you can convert a time that is stored as text into a valid VBA time.




  • Time: A string that represents a valid time as per VBA.


To practically understand how to use the VBA TIMEVALUE function, you need to go through the below example where we have written a vba code by using it:

Sub example_TIMEVALUE()
Range("B1").Value = TimeValue(Range("A1"))
End Sub

In the above code, we have used the TIMEVALUE to get the time value that we have in cell A1. Basically, there is a date with time and TIMEVALUE returned the time only.


  • It recognizes both types of time 12-hours and 24-Hours (“5:27 PM” and “17:27”).
  • If the time specified is a value other than a time or a string that can’t be recognized as a time, VBA will return the run-time 13 error.
Last Updated: June 22, 2023