© Roy Cox 2005 to 2013

Our Privacy & Cookie Policy

Where to put your Excel VBA Code

Add Excel VBA Code to a Workbook Module

If the Excel VBA code is Workbook Event code, it should be added to the workbook code module:

There are many sources that you may find code that you want to incorporate into your own project such as Forums or Excel help sites like this one.   Most Excel VBA code can be added by doing one of the following:

Add Excel VBA Code to a Standard Module

Note: In versions including and after Excel 2007 you will find the Macros button in the Developer's Tab

Add Excel VBA Code to a Worksheet Module

Some code is Event code, and will run automatically when a specific action occurs in  the worksheet For example, if you type in a cell, and press the Enter key, the worksheet has been changed. This would trigger the Worksheet_Change event. Worksheet event code is stored on a worksheet module. To add it to your worksheet, do the following:

View the WorkSheet Code Module

Drag and Drop from Workbook to another

Many Excel users are not aware that you can copy all the code in a module by doing the following: