What is VBA SECOND Function
how to use it
To use VBA's SECOND function you need to understand its syntax and arguments:
- Time: A valid time as per VBA from which you want to get the seconds value.
Example to use SECOND Function in VBA
To practically understand how to use VBA SECOND function, you need to go through the below example where we have written a vba code by using it:
Sub example_SECOND() Range("B1").Value = Second(Range("A1")) End Sub
In the above code, we have used the SECOND function to get the seconds from the time which we have in the cell A1 and in the result, it has returned 26.
Below are some important points which you need to take care while using SECOND function in VBA.
- If the supplied time value is NULL, then it will return NULL.
- If the value specified is a value other than a valid time or a string that can’t be recognized as a valid time, VBA will return the run-time 13 error.
About the Author
Puneet is using Excel since his college days. He helped thousands of people to understand the power of the spreadsheets and learn Microsoft Excel. You can ﬁnd him online, tweeting about Excel, on a running track, or sometimes hiking up a mountain.