If you often work with Microsoft Excel you might come to the point when standard functions won’t solve your problems any longer. In such case, you might have to start working with VBA macros. Of course, you can record steps in VBA, but usually you start from the opposite direction: You google a solution for your problem and find some VBA code snippets. Also, many of my articles contain short VBA codes. But how to use them? This article summarizes how to insert a new VBA module and paste some code in Excel.
Steps to insert a new VBA module
At first, you have to insert a new VBA module.
Start, as usual, in Excel.
- Open the VBA editor. The fastest way to do this would be to press Alt + F11 on the keyboard.
Alternatively, go to the Developer ribbon (if you don’t see the developer ribbon, you must activate it first) and click on Editor.
- Right-click on the Excel file VBA name (or any other item below, for example the “Microsoft Excel Objects” folder icon as in the screenshot).
- Go to “Insert” and click on “Module”.
Next: Paste your code and run it
After you have inserted a new VBA module, you can paste and run your macro:
- Now it should look similar to number 4 and you see the white code area in which you can paste the VBA source codes from below.
- Make sure that your cursor is located within your pasted code. Then, click on the green Start button to run the macro. Alternatively, press F5 on the keyboard.
More help on VBA macros
You need more help with VBA macros? Please refer to this article. It provides an overview of the first steps.