Excel VBA Minute Function
The Minute function in VBA returns the minute component for the specified time.
Syntax
Minute (Time)
Parameter
Time (required) – This parameter represents the time.
Return
This function returns the minute component for the specified time.
Example 1
Sub MinteFunction_Example1() ' Extracting the minute element from the given time Const Time_Val = "6:16:53" Dim minute_val As Integer minute_val = Minute(Time_Val) ' The variable minute_val will return 16. Cells(1, 1).Value = minute_val End Sub
Output
16
Example 2
Sub MinteFunction_Example2() ' Extracting the minute element from the given time Dim Time_val Time_val = Time() Dim minute_val As Integer minute_val = Minute(Time_val) ' The variable minute_val will return 29. Cells(1, 1).Value = minute_val End Sub
Output
29
Example 3
Sub MinteFunction_Example3() ' Extracting the minute element from the given time Dim Time_val Time_val = "Hello " Dim minute_val As Integer minute_val = Minute(Time_val) ' The variable minute_val will return type mismatch error. Cells(1, 1).Value = minute_val End Sub
Output