Excel VBA, Vertical Alignment

In this article I will explain the different vertical alignment formattings applicable to cells and ranges. I have also provided the VBA code required to apply them.

Jump To:


Top, xlTop:

The following code will top align the text in cell “A1”:

Range("A1").VerticalAlignment = xlTop

Result:

Top, xLTop, Excel VBA


Center, xlCenter:

The following code will center align the text in cell “A1” in the vertical direction:

Range("A1").VerticalAlignment = xlCenter

Result:

Center, xLCenter, Excel VBA


Bottom, xlBottom:

The following code will bottom align the text in cell “A1”:

Range("A1").VerticalAlignment = xlBottom

Result:

Bottom, xlBottom, Excel VBA


Justify, xlJustify:

The vertical justify formatting will be apparent when you have a 90 deg orientation and the text wrap is checked. The following code applies the verticle justify formatting to cell “A1”:

Range("A1").VerticalAlignment = xlJustify

Before:

Justify Verticle, xlJustify, before Excel VBA

After:

Justify Verticle, xlJustify, After Excel VBA


Distributed, xlDistributed:

The vertical distributed formatting will be apparent when you have a 90 deg orientation and the text wrap is checked. The following code applies the vertical distributed formatting to cell “A1”:

Range("A1").VerticalAlignment = xlDistributed

Before:

Distributed Verticle, xlDistributed, before Excel VBA

After:

Distributed Verticle, xlDistributed, After Excel VBA

See also:

If you need assistance with your code, or you are looking for a VBA programmer to hire feel free to contact me. Also please visit my website www.software-solutions-online.com

Leave a Reply

Your email address will not be published. Required fields are marked *

Search