How to Insert New VBA Module in Excel & Paste Macro Code

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.

Steps for inserting a new VBA module in Excel.
Steps for inserting a new VBA module in Excel.

Start, as usual, in Excel.

  1. 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.
  2. 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).
  3. 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:

Paste your code and click on Start to run your code.
Paste your code and click on Start to run your code.
  1. 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.
  2. 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.

Image by Meine Reise geht hier leider zu Ende. Märchen beginnen mit from Pixabay

Henrik Schiffner is a freelance business consultant and software developer. He lives and works in Hamburg, Germany. Besides being an Excel enthusiast he loves photography and sports.

Leave a comment

Your email address will not be published. Required fields are marked *