auto fit & horizontal alignment not working

P

petedacook

I have some code that is not centering and formatting all of the columns. I
have coppied the snippet of code that his adjusting the alignment and
autofit. Can anyone tell why the code is not formatting all of the cells?

Columns("A:R").EntireColumn.Select
With Selection.EntireColumn
Cells.EntireColumn.AutoFit
HorizontalAlignment = xlCenter
VerticalAlignment = xlBottom
End With




Thanks!!
 
G

Gary Keramidas

here's how i'd do it:

Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws.Columns("A:R")
.AutoFit
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top