VBA MINUTE Function

VBA MINUTE Function in Excel

VBA Minute Function in Excel is a built-in function in MS Excel. It has one input argument or parameter. VBA Minute Function returns the two-digit number as Minute from the specified time and returns a number from 00 to 59 (It has a leading zero where applicable). It is a ‘Data and Minute’ type function. Default format of the Minute function is ‘MM’. The VBA Minute Function can be used in either procedure or function in a VBA editor window in Excel. We can use the VBA Minute Function any number of times in any number of procedures or functions. In the following section we learn what is the syntax and parameters of the Minute function, where we can use this VBA Minute Function and real-time examples.

Syntax of VBA Minute Function

The syntax of the VBA Minute Function is

MINUTE(time_value)

Parameters or Arguments

There is one parameter or argument for the Minute function in VBA. That is nothing but ‘time_value’.
Where time_value is a time to generate number as Minute from the specified time. It returns a number from 00 to 59. It has leading zero where applicable.

Where we can apply or use the VBA Minute Function?

We can use this VBA Minute function in MS Office 365, MS Excel 2016, MS Excel 2013, 2011, Excel 2010, Excel 2007, Excel 2003, Excel 2016 for Mac, Excel 2011 for Mac, Excel Online, Excel for iPhone, Excel for iPad, Excel for Android tablets and Excel for Android Mobiles.

Example 1: Display current Minute on the screen

Here is a simple example of the Minute Function. This below example macro uses the Minute function and displays the two-digit Minute from the specified date. In this case specified time is current time.

'Display Current Minute on the screen
Sub VBA_Minute_Function_Example1()
    
    'Variable declaration
    Dim sCurrentMinute As Integer
    
    'Assign current Minute to variable
    sCurrentMinute = Minute(Time)
    MsgBox sCurrentMinute, vbInformation, "Current Minute"
    
End Sub 

In the above example ‘sCurrentMinute’ declared as an Integer data type. And Minute is a vba function, it returns two digit number (number from a 0 to 59) as Minute. This variable ‘sCurrentMinute’ now contains the two-digit Minute.
Output: Here is the screen shot of first example output.
VBA MINUTE Function Example 1

Example 2: Display current Minute on the Worksheet

Here is another example of the VBA Minute Function. This below example macro uses the Minute function and displays the Minute from the specified time on the Worksheet named ‘VBAF1.Com’ in Range ‘B18’.

Sub VBA_Minute_Function_ Example2()
'Display Current Minute on the Worksheet
   
    'Variable declaration
    Dim dCurrentMinute As Date
    
    'Assign current Minute to variable
    sCurrentMinute = Now
    Sheets("VBAF1.com").Range("B18") = Minute(sCurrentMinute)
    
    'or
    'Sheets("VBAF1.com").Cells(18, 2) = Minute(sCurrentMinute)
    
End Sub
    

Output:Here is the screen shot of second example output.
VBA MINUTE Function Example 2

Example 3: Display Medium Time on the screen using Format

Here is one more example with Minute Function. This below example macro uses the Time function and changes the format of the time. Finally, it displays the medium time from the specified time on the screen. Long time includes hours, minutes and the Am/PM indicator.

Sub VBA_Minute_Function_ Example3()
'Format and Display medium Time on the screen    
    'Variable declaration
    Dim sCurrentMinute As Date
    
    'Assign current Minute to variable
    sCurrentMinute = Time
    MsgBox Format(sCurrentMinute, "Medium Time"), vbInformation, "Current Medium Time"
    
End Sub

Output:Here is the screen shot of third example output.
VBA MINUTE Function Example 3
Note: Difference between first output and second output is format of the Minute.

Download File

Click on following link to download free example excel workbook to learn more about the Minute function.

VBA Minute Function Examples

Instructions to Run VBA Macro Code or Procedure:

You can refer the following link for the step by step instructions.

Instructions to run VBA Macro Code

Other Useful Resources:

Click on the following links of the useful resources. These helps to learn and gain more knowledge.

VBA Tutorial VBA Functions List VBA Arrays in Excel Blog

VBA Editor Keyboard Shortcut Keys List VBA Interview Questions & Answers

Leave a Reply