VBA: Change Excel cell width

Use this:

Range("A1").ColumnWidth = ...

The units for this value are as following:

One unit of column width is equal to the width of one character in the Normal style. For proportional fonts, the width of the character 0 (zero) is used.

For example, the column width for freshly opened Excel file with default styles is 8.43 which is equal to 64 pixels.

...or this to autofit width:

Range("A1").EntireColumn.AutoFit

Another method would be:

.Columns("A").ColumnWidth = 20 (or whatever value you need)

I didn't compare it speedwise but why my guess would be that it's more efficient to just use Columns() instead of Range().

For more info on the ColumnWidth-Value -> MSDN Doc for the columnwidth-property

Tags:

Excel

Vba