The below code selects the sheet but fails to align the cells to center:
wb.Sheets(1).Columns("A:L").Select
With Selection
.VerticalAlignment = xlCenter
End With
wb.Sheets(1).Activate
wb.Sheets(1).Columns("A:L").Select
With Selection
.VerticalAlignment = xlCenter
End With
Selects the entire sheet but it’s not changing the vertical alignment to center.
wb.Sheets(1).Columns("A:L").VerticalAlignment = xlCenter
I don’t want HorizontalAlignment.
I found the column has VerticalAlignment set to xlCenter but the Cells underneath the column do not have VerticalAlignment set to xlCenter.
Don’t
Selectand don’t work withSelectionwithout a reason. That’s Recorder’s stuff. It is longer to read, slower to execute, and prone to error.wb.Sheets(1).Columns("A:L").VerticalAlignment = xlCenteris much better.If you need to do several things with the same range, then use
With