TimeSerial VBA function – How to create time from parts

Last Updated on January 11, 2023 by token

1. TimeSerial VBA Function – Description

The TimeSerial VBA function  returns the time composed of arguments such as hour , minutesecond . If in VBA you have numbers representing hours, minutes, seconds and you want to compose time from them, use the TimeSerial function. In case you want to combine the elements not the time but the date, use the VBA DateSerial function .

2. VBA TimeSerial function – Syntax

TimeSerial (Hour As Integer, Minute As Integer, Second As Integer)

Hour – A number that represents an hour in time

Minute – A number that represents the minutes in time

Second – A number representing seconds in time

Function return:  Date / A value representing a time

3. VBA TimeSerial function – Example

How to use TimeSerial function in VBA Excel? Below is an example of using the TimeSerial function in the VisualBasic Editor.

Example 1:

Range ("A1") = TimeSerial (16, 52, 21)
MsgBox TimeSerial (12, 55, 59)

Example 2:

Dim intHour As Integer
Dim intMinute As Integer
Dim intSecond As Integer

intHour = 23
intMinute = 12
intSecond = 32

MsgBox TimeSerial (intHour, intMinute, intSecond)
Range ("A2") = TimeSerial (intHour, intMinute, intSecond)
VBA Excel functions - TimeSerial VBA function
VBA Excel functions – TimeSerial VBA function

4. VB TimeSerial function – Additional information

  • lack

5. TimeSerial VisualBasic function – Where to use?

The function can be used in: Excel 2003, Excel 2007, Excel 2010, Excel 2013, Excel 2016, Excel 2019, Excel 2021, Excel 365.

The article is part of the VBA Excel function list. You can find a list of all VBA functions at this address:  VBA functions .

Leave a comment

Your email address will not be published. Required fields are marked *

%d bloggers like this: