Thursday, 20 September 2012

Excel VBA Macro for Data AlignMent

Excel VBA Macro for Data AlignMent

Sub AlignCorrect()
Dim x As Integer
Dim y As Integer


For x = 2 To 500
For y = 1 To 26

Cells(x, y).Rows.RowHeight = 15
Cells(x, y).Columns.ColumnWidth = 15
Cells(x, y).VerticalAlignment = xlCenter
Cells(x, y).HorizontalAlignment = xlCenter


Next y
Next x

End Sub


Some Valid  Alignments:

Horizontal:
xlGeneral
xlLeft
xlRight
xlCenter

Vertical:
xlTop
xlBottom
xlCenter

No comments:

Post a Comment

Follow Me by Email

ExcelKingdom-Popular Posts

ExcelKingdom-Random Posts