Create a Macro Function in MS Excel
In this tutorial, we will learn the steps involved to Create a Macro Function in an MS Excel document. Macros are disabled by default due to security reasons. We need to save the Excel Workbook with macros in it with the Macro-enables Save option.
Create a Macro Function
Open Start Menu and click the Excel application icon.
Open an Excel Document. Click the Blank workbook option.
This will open a new blank Excel workbook.
Click on the Developer tab. ->> Macros button in the Developer ribbon menu.
In case, if the Developer tab is not present in the menu. Follow the steps outlined here:
We can find the Macros button in the Developer ribbon.
Enter the Macro name. Click on the Create button to create the macro.
Choose the scope of the Macro:
- All Open Workbooks
- This Workbook
We will create a macro function to print “Hello World”. The macro name is MyFirstMacro()
Add the following simple macro code:
Function MyFirstMacro() MyFirstMacro = "Hello World" End Function
Invoke the Macro
In the Excel sheet, Choose a cell to call the macro function. Start typing the function name.
Excel would prompt with the function. Select it.
That’s it. A successful macro would print the Hello World message in the excel sheet cell.