July 24, 2011

VBA Code Indenter

There are 2 VBA code indenters that I know of, and unfortunately, I am not able to install either of them where I need them most to due to admin rights. With "complex" code, indenting can help a lot by making code easier to read so I decided to make my own.

My own version is rather basic. You can either indent a whole project or selected module. The menu items are available at the bottom of the right click menu in the Code Pane.

VBA Code Indenter


Note that you must tick Trust access to the VBA project object model before installing. Here is how to do it with various Excel Versions.

Pre-2007
Go to the Tools Menu at the top of Excel. Select Macros, Security, then Trusted Sources. Tick "Trust access to Visual Basic Project".

Excel 2007
Go to the Developer tab at the top of Excel. Select Macro Security, Macro Settings and then tick "Trust access to the VBA project object model."

If the Developer tab is not visible, select the round Office button at the top of Excel, then Excel Options, Popular, "Show Developer tab in the Ribbon."

Excel 2010
Go to the Developer tab at the top of Excel. Select Macro Security, Macro Settings and then tick "Trust access to the VBA project object model."

If the Developer tab is not visible, select the File button at the top of Excel, then Options, Customize Ribbon and tick Developer on the Customize the Ribbon, Main Tabs list.



Here is the download link to try it out.