How To Increase Indent In Excel



So I just learned that the Excel shortcut for increasing indents is Ctrl-Alt-Tab, and decreasing is Ctrl-Alt-Shift-Tab. However, these are both captured by Windows and result in the version of Alt-Tab which stays on the screen until a selection is made. Click on the “Alignment” tab and then open the “Horizontal” drop-down menu in the “Text Alignment” section. For extra space between cell text and the left or right cell border, click “Left (Indent)” or “Right (Indent).”. This shortcut increases the indent in a cell by one step each time it is used. On Windows, you can sometimes use Ctrl+Alt+Tab to indent and Ctrl+Alt+Shift+Tab to un-indent. However, The application switcher in Windows 7 seems to conflict with these shortcuts. On the Mac, Ctrl+M and Cmd+Shift+Tab also work. To get multiple lines within a cell use Alt + Enter to start a new line within the cell. To indent any line simply use spacebar a few times. In Excel 2010, the General Options tab is found by clicking File Options General: If the indentation looks different for two different Excel files, my guess is: you will see differences in the General Options. Another way to control the 'indentation' width is to use the underscore specifier in a Custom format.

How to change indent number in excelHow to increase indent in excel in cell

What is Excel VBA Indentation?

Indentation represents some spaces at the beginning of a new row of sentence. Indentation is not a word reserved for VBA, it is a word that also appears in Microsoft Word, Excel spreadsheet and even Powerpoint. Indentation is also used for all kinds of computer programming.

How To Increase An Indent In Excel

In VBA coding, indentation is not mandatory, which means it does not cause compile error if you miss it, but it is definitely a good practice for you or for others to follow your code easily. There is no black and white rule for what code needs to be indented, but there are generally acceptable rules.

Why do you need Excel VBA Indentation?

I will show an example below for you to understand more easily. The below code has no indentation.

Now with indentation

The first code is difficult to read because it looks like a mess, all codes combine together.

How To Change Indent In Excel

The second code is easier because codes are in different layers.

Rules of Excel VBA Indentation

There are some generally acceptable rules for indentation

1) For each set of code that has an starting and ending keyword such as IF…End If, indent the lines of code between. Use “Tab” key for indentation, Shift+Tab to undo the Tab effect.

2) Do not need to indent code that has starting keyword but no ending keyword in separate line, such as Dim xxx As Integer

2) Double line spacing is optional, just use it if it makes you easier to read

3) Do not worry about spacing within each line of code, it will be adjusted automatically

Example 1

Indent the codes between Sub and End Sub

Example 2

Indent the codes between If and End If

Example 3

How To Increase Indent In Excel

Indent the codes between For /Next and nested IF / Else / End IF

Just ignore what the code means, focus on the indentation.

VBE Option – Auto Indent

VBE (Visual Basic Editor) has an option called Auto Indent, but it does not automatically indent all lines of code. Auto Indent functions when you press Enter key to start a new line, if the code before you press Enter has indentation, the new line will begin at the position of the previous indentation. If you don’t turn on the Auto Indent function, the next line will start on the left.

How To Increase Indent In Excel 2016

In VBE, navigate to Tools > Options >Editor Tab

Check the box Auto Indent to enable the option, you can also specify Tab width, the default value is 4, you can leave it as is.

Shortcut To Indent In Excel

Outbound References