Thursday, September 20, 2012

How to do Data Alignment using Excel VBA Macro

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

Thanks,Tamatam

No comments:

Post a Comment

Hi User, Thank You for visiting My Blog. If you wish, please share your genuine Feedback or comments only related to this Blog Posts. It is my humble request that, please do not post any Spam comments or Advertising kind of comments, which will be Ignored.