How to make a button to run your macro in Excel

If the macro was created earlier and is stored in the workbook or add-ins, its launch can be performed in several available ways. But, if it is not there, then first you will have to try to create it.

We write a macro ourselves in Excel

Let’s look at an example of creating a simple macro. When faced with the problem of constantly creating tables with the same header, it is more convenient to create your own macro. After launch, it will display a finished table with captions in the header. Consider step by step instructions:

  1. Go to the “Developer” tab and find the “Code” tool group.
  2. There is a record button in the upper corner of the block. It has the shape of a leaf and a red round dot, symbolizing writing.
  3. After activating the icon, a window will open where, if necessary, you need to fill in some lines. For example, rename the macro (in our case, it is “Table Header”), set the hot key combination (Ctrl + f) and the location for saving the macro (there are three options: personal macro book, new book or this book). To make it easier, it is recommended to make a description.

How to make a button to run your macro in Excel

  1. After all the lines are filled with information, click the “OK” button. Thus, consent was given to the previously performed actions and the macro recording was started automatically.

How to make a button to run your macro in Excel

  1. Create a table header with written informational headings. At the end of the steps, end the recording of the macro by clicking the record button again. As a result, the macro will be saved automatically.

How to make a button to run your macro in Excel

Note from an expert! To run the created macro in a new document, you must activate the “Relative Links” button located under the record button. If the activation of relative links has not been made, then the macro will automatically run only in the document where it was created.

Now that we have dealt with one of the ways to create a macro using an example, let’s look at several options for running them in Excel.

Run a VBA Macro

The launch is easy to understand, but can be tricky to launch:

  1. Having opened a new document in which it is planned to work with tables, go to the “Developer” tab.
  2. Here we turn to the “Code” tool group and click on the “Macros” line. The tool is launched by hotkeys “Ctrl+F8”.

How to make a button to run your macro in Excel

  1. In the window that opens, find the desired macro (Table header) and click “Run”.

At this point, the macro program will open on its own and automatically execute the previously scheduled command. For our macro, this is the creation of a table header with inscribed column headers.

How to make a button to run your macro in Excel

Expert advice! Excel has the ability to edit macros. To do this, go to the previously specified path to the Macro tool and open the window. Having selected the macro that needs editing, click on the “Enter” button, after which a tab with the recorded code will open, where you can edit it yourself.

Running macros with hotkeys

The advantage of this method is that to go to the desired macro, just hold down the key combination. To do this, however, the combination must be assigned to a macro program. Let’s see how to do this below:

  1. Follow the known path to the Macros tool and activate the window opening.
  2. Next, click on the “Settings” link.
  3. Choose the most suitable keyboard shortcut (memorable and not conflicting with speed dialing in Excel). How to make a button to run your macro in Excel

Expert note! The Ctrl key is a fixed value and cannot be changed. Only secondary keys can change. The Shift key can also be added as an additional link.

  1. Agree with the actions performed by clicking the “OK” button.

After that, to call the macro, just press the key combination previously assigned to it.

Activating a Macro from the Quick Access Toolbar

This function block can be found at the very top of the program. It only contains a few default buttons. There, at the request of the user, others can be added, including a self-created macro. How to do this, let’s look at a simple example:

  1. At the top of the screen – to the left of the “Save” button with a label in the form of a floppy disk, as well as the buttons for canceling and redoing completed actions – there is an icon with a down arrow.
  2. By clicking on it, a list with the functionality of quick access settings will open. Select More Commands.
  3. In the “Excel Options” window, find the “Choose a command from:” drop-down list, by clicking on the icon on the right, stop your choice on “Macros”. How to make a button to run your macro in Excel
  4. As a result, the program will display a list of all available macros. You need to select one and click “Add”.
  5. The macro should move to the right column, where you need to specify the use of “For all documents” in the drop-down list. Click “OK” and editing is complete.

How to make a button to run your macro in Excel

For the convenience of working with a macro, you can change the appearance of the icon on the quick access panel:

  1. Go to the “Excel Options” window and on the Quick Access Toolbar find the moved macro icon.
  2. Activate it and click on the “Change” button below.

How to make a button to run your macro in Excel

  1. A window will open with various icons. Choose the one you like and click OK.
  2. As a result, you will get a ready-made macro on the quick access panel with a changed appearance of the icon.
  3. To activate the macro, it will be enough to click on the icon, and it will automatically be launched. How to make a button to run your macro in Excel

Conclusion

A self-created macro is the best solution to some issues. However, in order for it to be accessible and as useful as possible, it is recommended to study the material with ways to open a macro program, create an individual icon and the ability to use hotkeys for quick opening.

Leave a Reply