totn Excel Functions

MS Excel: How to use the TIMEVALUE Function (WS, VBA)

This Excel tutorial explains how to use the Excel TIMEVALUE function with syntax and examples.

Description

The Microsoft Excel TIMEVALUE function returns the serial number of a time.

The TIMEVALUE function is a built-in function in Excel that is categorized as a Date/Time Function. It can be used as a worksheet function (WS) and a VBA function (VBA) in Excel. As a worksheet function, the TIMEVALUE function can be entered as part of a formula in a cell of a worksheet. As a VBA function, you can use this function in macro code that is entered through the Microsoft Visual Basic Editor.

Syntax

The syntax for the TIMEVALUE function in Microsoft Excel is:

TIMEVALUE( time_value )

Parameters or Arguments

time_value
A string representation of a time. This can not be a date/time value. It must be a string.

Returns

The TIMEVALUE function returns a serial number of a time.

Applies To

  • Excel for Office 365, Excel 2019, Excel 2016, Excel 2013, Excel 2011 for Mac, Excel 2010, Excel 2007, Excel 2003, Excel XP, Excel 2000

Type of Function

  • Worksheet function (WS)
  • VBA function (VBA)

Example (as Worksheet Function)

Let's look at some Excel TIMEVALUE function examples and explore how to use the TIMEVALUE function as a worksheet function in Microsoft Excel:

Microsoft Excel

Based on the Excel spreadsheet above, the TIMEVALUE examples would return the following values:

=TIMEVALUE(A1)
Result: 0.584733796

=TIMEVALUE(A2)
Result: 0.084733796

=TIMEVALUE(A3)
Result: 0.646261574

=TIMEVALUE("5:12:00 AM")
Result: 0.216666667

Example (as VBA Function)

The TIMEVALUE function can also be used in VBA code in Microsoft Excel.

Let's look at some Excel TIMEVALUE function examples and explore how to use the TIMEVALUE function in Excel VBA code:

Dim LTime As Date

LTime = TimeValue("18:30:12")

In this example, the variable called LTime would now contain the value of 6:30:12 PM.