How to insert a ready-made macro into a workbook

A macro is a software algorithm of actions that is recorded by the user himself. When it is activated, several actions are automatically performed that the user has added to the general algorithm. This allows you to save time on routine tasks that are regularly repeated when working in various programs.

If we talk about macros in Excel, they are code that has been created through the VBA language. They can be created through the macro recorder or manually. After creating an action algorithm, it can be run an unlimited number of times to perform repetitive operations. However, the process of adding a macro to a workbook needs to be considered in more detail, since any wrong action will cause the algorithm to work incorrectly or lead to various errors.

How to record a macro

Before you can add an action algorithm to a workbook, you must create it. To do this, you can use two methods:

  • manually;
  • automatically.

In order to create a macro automatically, it is enough to record a certain procedure through Excel. However, they must be carried out at the moment. When the recording is finished, it can be applied to other tables by clicking on play. The main advantage of this method is that there is no need to learn the code in order to put it into practice.. However, such an algorithm will not have any flexibility, it can only be applied in certain situations.. The process of automatic macro recording:

  1. Initially, you need to go to the “Security Control Center” through the main menu of the program.
  2. Go to the “Macro Options” tab.
  3. Activate the “Enable all macros” command.
How to insert a ready-made macro into a workbook
Activating macros in Excel’s original settings
  1. Go to the “Developer” tab, which is located on the main toolbar.
  2. Click on the “Record macro” button (it is located in the toolbar called “Code”).

Next, a window with the algorithm settings will open, where you need to come up with a name for the macro, set the key combination to run it. After completing the settings, you must confirm the specified parameters with the “OK” button.

Important! To open the panel with ready-made macros, you need to press the key combination Alt + F8. It calls up a window with already created algorithms, from which you need to select the desired option.

How to add a ready-made macro to a workbook

Those users who do not have serious programming experience or do not want to write code for a certain algorithm of actions on their own need to learn how to add ready-made text to worksheets. Procedure for adding a ready-made macro:

  1. Initially, you need to find the desired team on the Internet. After that, select the resulting code.
  2. Launch workbook, activate Alt+F key combination
  3. A VBA window should open before the user.
How to insert a ready-made macro into a workbook
Window for settings, adding macros manually if you have a ready-made code
  1. On the left side, you need to find the “Project – VBA Project” window. Select a workbook from the list that appears.
  2. Open the “Insert” menu, activate the “Module” function.
  3. After that, a new folder called “Modules” will appear in the left window.
  4. Open a new object inside the created pack, paste the copied code into a free window using the key combination “Ctrl + V”.
How to insert a ready-made macro into a workbook
Adding code and saving it for further use of the algorithm of actions

It remains to close the running editor, return to the workbook.

Important! To save a finished table with an added macro in Excel versions 2007, 2010, 2013, you need to select the line “Excel workbook with macro support” from the file type list.

How to run a macro

There are several proven ways to run added or created action algorithms in Excel. The easiest method is to run the macro via VBA:

  1. Go to the “Developer” tab on the main toolbar.
  2. Go to the “Code” toolbar, click on the “Macros” button.
  3. From the window that opens, you need to select the required algorithm with the help of LMB, click on the “Run” button.

After that, the algorithm will be executed. Macro activation via key combination:

  1. It is necessary to enter the window with ready-made or added algorithms of actions in the same way as described in the method above.
  2. Go to the “Settings” tab, which is located on the right side of the window that appears.
  3. Another window will open in which you can configure the algorithm.

Among the available options, you must select the field to add a key combination with which you can call the macro.

Advice! In the window with parameters there is a large free field at the bottom, which has the name “Description”. It is recommended to write briefly what actions this algorithm performs. This will help you not to get confused in the created macros when using them.

Running the algorithm through the quick access panel:

  1. On the Quick Access Toolbar, find the down arrow icon.
How to insert a ready-made macro into a workbook
Adding a Macro to the Quick Access Toolbar
  1. From the list that opens, select the “Other commands” function. A window with Excel options should appear.
  2. From the list on the left side, go to the “Choose a team” tab. Click on the “Macros” function.
  3. Next, you need to select the desired algorithm of actions.
How to insert a ready-made macro into a workbook
Available list of images for the icon of quick access to the algorithm of actions

The custom icon for the selected macro should appear in front of the down arrow on the Quick Access Toolbar. It can be changed through the settings. To save the set parameters, you must click the “OK” button.

Important! This method has one drawback that is important to consider before adding a workflow button to the Quick Access Toolbar. The macro access icon will be available in all worksheets. Clicking on it will open the document where it was originally added.

Conclusion

Most of the useful macros for Excel are freely available on the Internet. It is enough to copy the source code, add it to the workbook according to the instructions described above. Thanks to this method, you do not need to memorize the process of writing code, you can save time on certain actions.

Leave a Reply