Friday, August 12, 2016

How to use the TIMEVALUE Function (WS,VBA)

Description

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

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.

Applies To

  • 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.

No comments:

Post a Comment