totn Excel Functions

MS Excel: How to use the TIMESERIAL Function (VBA)

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

Description

The Microsoft Excel TIMESERIAL function returns a time given an hour, minute, and second value.

The TIMESERIAL function is a built-in function in Excel that is categorized as a Date/Time Function. It can be used as a VBA function (VBA) in Excel. 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 TIMESERIAL function in Microsoft Excel is:

TimeSerial( hour, minute, second )

Parameters or Arguments

hour
A numeric value between 0 and 23 that represents the hour value of the time.
minute
A numeric value that represents the minute value of the time.
second
A numeric value that represents the second value of the time.

Returns

The TIMESERIAL function returns a time value.

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

  • VBA function (VBA)

Example (as VBA Function)

The TIMESERIAL function can only be used in VBA code in Microsoft Excel.

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

TimeSerial(14, 6, 30)
Result: 2:06:30 PM

TimeSerial(20 - 8, 6, 30)
Result: 12:06:30 PM

TimeSerial(8, 6-2, 14)
Result: 8:04:14 AM

TimeSerial(7, -15, 50)
Result: 6:45:50 AM

For example:

Dim LTime As Date

LTime = TimeSerial (23, 5, 31)

In this example, the variable called LTime would now contain the value of "11:05:31 PM".