VBA Code Indenter

VBA Input Clear
Indent Options: Indent Entire Procedure Body
Indent First Comment Block in Procedure
Indent First Declaration Block in Procedure

Indent Case in Case Select
Alignment Options: Align Variable Type in Variable Declarations

Align Comments with Code
Align Line Continuations
Ignore Operators
Remove Excess Line Breaks
Output

Code Cleaner Overview:

This VBA code formatter allows you to easily beautify your code by auto-indenting and cleaning up excess line breaks. You can also "Pretty Print" your VBA code to a PDF for documentation or for easier review.

Step by Step Instructions to Format Code

  1. Copy and Paste your VBA Code into into the "VBA Input" area on the left
  2. Press the 'Indent' button in the middle of the screen. Your new "beautified" code will appear on the right.
  3. Change the code indentation options in the middle of the screen. Your changes will be reflected in real-time
  4. Copy and Paste your VBA code back into the VBA Editor.

VBA Auto-Indenter

 This tool will automatically indent your code based on your choosen indentation settings:

  • Indent Entire Procedure Body - Will all code in procedure be indented one spot or not?
  • Indent First Comment Block in Procedure - The first comment block is often used to document the procedure functionality. Do you want to indent this or not?
  • Indent First Declaration Block in Procedure - Do you want to indent the first block of variable declarations?
  • Indent Case in Case Select - Do you want to indent Case's within a Case Select Statement?

And Based on the following Code Alignment Options:

  • Align Variable **type** in Variable Declarations - This aligns the variable types in lines with variable declarations - it can make your code easier to read.
  • Align Comments with Code - If unchecked, comments will by un-indented
  • Align Line Continuations - Used with the line continuation symbol "_" to extend a line

VBA Code Cleaner

 The VBA Indenter can also clean your code by removing excess line breaks. Excess line breaks are when there are more than two consecutive blank lines. 

VBA Pretty Print

After you format your VBA Code, you can elect to Pretty Print your code to a PDF. Pretty printing generates a PDF of your VBA code with the standard VBA syntax highlighting, allowing you to easily review your code.

 

VBA Auto-Indentation Add-in

VBA Code Indenter

We also offer a VBA Code Indenter Add-in. The indentation tool is free to use. However, the add-in also offers many premium features:

VBA Code Formatter