VBA: Change Excel Cell Width

I have VBA and batch scripts that read a Mac address table from some switches and import it into Excel to format it.
But the text is too long for the default cell width.

Can I change the displayed cell width?

(When they say that the displayed cell width, I mean: this )

+6
source share
1 answer

Use this:

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

The units for this value are as follows:

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

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

... or is this the value of the auto-tuning width:

 Range("A1").EntireColumn.AutoFit 
+12
source

All Articles