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 , minute , second . 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.
Range ("A1") = TimeSerial (16, 52, 21) MsgBox TimeSerial (12, 55, 59)
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)
4. VB TimeSerial function – Additional information
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 .