Thursday, March 5, 2009

Excel VBA: Cell Alignment

In Excel VBA macro we can control the alignment of cell, both horizontally and vertically. To change alignment, we can use the following properties of the Range object:
  • HorizontalAlignment. Set to xlLeft, xlCenter, xlRight, xlDistributed, or xlJustify.
  • VerticalAlignment. Set to xlTop, xlCenter, xlBottom, xlDistributed, or xlJustify.
Following example sets horizontal alignment to justify:

Worksheets("Sheet1").Range("A1:D5").HorizontalAlignment = xlJustify

Related Post:
If you like posts in this blog, you can to support me :)

No comments:

Post a Comment