How to Enable & Run a Macro in Excel? 6 Ways
Last Updated :
06 Dec, 2023
We can record a macro in Excel or write from scratch in VB Editor. Excel provides different options to run a macro. In this article, we explore four different approaches to running a macro in an Excel application.
Even while executing an Excel macro is a straightforward process for seasoned users, it might not be clear to newbies. You will discover numerous ways to execute macros in this article, some of which may entirely alter the way you interact with Excel files.
The below macro will write the text “Geeks for Geeks” in cell B5
Sub updateText()
ActiveSheet.Range("B5").Value = "Geeks for Geeks"
End Sub
How to Run a Macro from Excel Ribbon
Follow the below steps to run a macro in the Macro dialogue box:
Step 1. Go to View >> Macros >> View Macros – to pop-up Macro dialogue box [keyboard shortcut - Alt+F8].

Step 2. Select a Macro from the list (e.g. updateText) and Press “Run”

Output:

How to Run Macro from VBA Editor
Follow the below steps to run a macro in VBE:
Step 1. Open Excel
Step 2. Go to Developer>> Visual Basic – to open VBA Editor [keyboard shortcut - Alt+F11]

Step 3. Select anywhere in the macro code and click the “Run button” (Green Arrow) or Press F5

How to Run a Macro with Custom Keyboard Shortcut in Excel
Follow the below steps to assign a keyboard shortcut to execute a Macro:
Step 1. Go to View >> Macros >> View Macros – to pop-up Macro dialogue box [keyboard shortcut - Alt+F8]
Step 2. Select Macro from the list (e.g. updateText) and Press “Options”, to pop-up Macro Options

Step 3. Give any specific text in shortcut key input [e.g. Ctrl+p] and Press “OK”. Close Macro list

Step 4. Just press your Shortcut key, e.g. Ctrl+p, to execute the macro.
How to Create a Macro Button in Excel
Follow the below steps to add a shape in Excel to execute a macro:
Step 1. Click Insert in the Controls group of the Developer tab, then choose Button under From Controls. Add a button, “Run Macro”
Create a Macro Button
Step 2. Right-click Shape and Press “Assign Macro”, to pop up the Assign Macro dialogue box

Step 3. Select “updateText” Macro and Press “OK”

Step 4. Just click the shape “Run Macro” in your Excel file to run the macro
The macro can now be executed by clicking its button. The assigned macro formats the chosen cells as seen in the screenshot below.


How to Create a Macro Button from a Graphic Object
Unfortunately, button controls cannot have their appearance customized, which is why the button we just constructed does not look very beautiful. You can use shapes, icons, pictures, WordArt, and other things to create a really lovely Excel macro button.
Follow the below steps to create a Macro button from a Graphic Object:
Step 1. Select the Illustrations group, from the Insert Tab, Select Shapes, and choose the desired shape

Step 2. Click on your worksheet and then place the shape object there and create your shape button in the desired format
Step 3. Right-click the shape object, select Assign Macro from the context menu, then select the required macro and press OK to bind the macro to the shape

Now you have a shape that resembles a button and when you click on it, it executes the designated macro.
Run the macro by clicking on the shapeHow to Add a Macro Button to Quick Access Toolbar
The macro button added to a worksheet looks nice, but it takes time to add a button to every sheet. Add your preferred macro to the Quick Access Toolbar to make it accessible from anywhere.
Step 1. Use the context menu by right-clicking the Quick Access Toolbar and selecting More Commands

Step 2. Select Macros

We can make a few more adjustments or click OK to save the changes
Step 4. If the icon added turns out to be unsuitable for your macro, click Modify to change it to a different icon

Step 5. Select a desired icon for your macro button from the Modify Button dialogue box
Step 6. Click on OK once done
Well Done! You now have a button on Excel that will start a macro.

You just need to select the Excel macro execution method that best suits your requirements now that you are aware of the various available options. I appreciate your time and hope to see you on some of our other blogs.
Similar Reads
How to Delete a Module in Excel VBA? Have you ever seen a text file in a notepad or a source code file in visual studio code? These all are just basic files where you can write some code or information. Similarly, we have modules in excel, each module has its code window, where you can write some code and allow it to automate your repe
3 min read
How to Record a Macro in Excel Excel Macro is simply a record button that records a set of actions performed on Excel that can be run multiple times. For example, if you have to format some raw data on a weekly basis you can use a macro to record yourself formatting the data once and let Excel automate the task in the future. it'
11 min read
How to Insert and Run VBA Code in Excel? In Excel VBA stands for (Visual Basic for Application Code) where we can automate our task with help of codes and codes that will manipulate(like inserting, creating, or deleting a row, column, or graph) the data in a worksheet or workbook. With the help of VBA, we can also automate the task in exce
2 min read
How Can I Enable Python in Excel? Excel and Python are a dynamic combination that may help anyone improve their automation and data analysis skills. Not only can Python help you become more proficient with spreadsheets, but it can also revolutionize efficiency and insight. This is how to easily enable Python in Excel to open up a pl
3 min read
How to Run Code from a Module in Excel VBA VBA Macro is for developers. In Excel, the macro is a piece of code written in VBA and VBA is Microsoft's programming language, it stands for Visual Basic for Applications. The module is a file with a .bcf extension that stores the code written in the Visual Basic for Applications editor. Let's lear
4 min read