VBA Excel, Alignment
The following article explains the different alignment formattings applicable to cells and ranges and provides reference for more detailed explanation. When right click on a cell and select Format Cells … a dialog will open:
The dialog has an alignment tab:
The alignment tab displays all the possible alignment formattings applicable to cells and ranges. All these formatting options can be automated using VBA.
Jump To:
- Horizontal Alignment
- Vertical Alignment
- Orientation
- Wrap Text, WrapText
- Shrink to Fit, ShrinkToFit
- Merge Cells, MergeCells
- Reading Order
Contents
Horizontal Alignment:
Horizontal alignment applies to the formatting options provided by the drop down list and indent text box marked in the figure below:
For more information about using VBA to apply horizontal alignment formatting please see Excel VBA, Horizontal Alignment.
For examples of using horizontal alignment in VBA please see:
- Excel VBA, Set Horizontal Alignment, (Sample Code)
- Excel VBA, Get Horizontal Alignment (Sample Code)
Vertical Alignment:
Horizontal alignment applies to the formatting options provided by the drop down list marked in the figure below:
For more information about using VBA to apply vertical alignment formatting please see Excel VBA, Vertical Alignment.
For examples of using vertical alignment in VBA please see:
Orientation:
Orientation applies to the formatting option provided by the part marked in the figure below:
Using VBA you can do the following:
- Change the orientation of the content in a cell or range
- Get the current orientation of the content in a cell or range
For more information about using VBA to apply and get the orientation of cells and ranges please see Excel VBA, Orientation.
Wrap Text, WrapText:
Wrap Text applies to the formatting option provided by the check box below:
Using VBA you can do the following:
- Change the wrap text property of cell or range on and off
- Get the current wrap text property a cell or range
For more information about using VBA to modify and get the wrap text property of cells and ranges please see Excel VBA, Wrap Text On/Off.
Shrink to Fit, ShrinkToFit:
Shrink to fit applies to the formatting option provided by the check box below:
Using VBA you can do the following:
- Change the shrink to fit property of cell or range on and off
- Get the current shrink to fit property a cell or range
For more information about using VBA to modify and get the shrink to fit property of cells and ranges please see Excel VBA, Shrink to Fit On/Off.
Merge Cells, MergeCells:
Merge cells applies to the formatting option provided by the check box below:
Using VBA you can do the following:
- Merge multiple cells and ranges
- Separate merged cells and ranges
For more information about using VBA to merge and unmerge cells and ranges please see Excel VBA, Merge Cells.
Reading Order:
Reading order applies to the formatting options provided by the drop down list below:
Using VBA you can change the reading order of cells For more information about using VBA to change the reading order of cells and ranges please see Excel VBA, Reading Order.
See Also:
- VBA Excel, Font Formatting
- VBA Excel, Formatting Cells and Ranges Using the Macro Recorder
- Excel VBA, Get Cell Alignment Properties (Sample Code + Download)
- Excel VBA, Set Cell Alignment Properties (Sample Code + Download)
If you need assistance with your code, or you are looking to hire a VBA programmer feel free to contact me. Also please visit my website www.software-solutions-online.com