Excel Guides

Setting Column Width in a Macro in Excel

You can set column width in a macro in Excel by using the ColumnWidth property of the Range object. The following example sets the width of column A to 12 characters.

Range("A:A").ColumnWidth = 12

If you want to set the width of multiple columns, you can use a loop. The following example sets the width of columns A through C to 12, 14, and 16 characters, respectively.

For i = 1 To 3
    Columns(i).ColumnWidth = i * 2 + 10
Next i

Move beyond 

Excel

Get started with Causal today.
Build models effortlessly, connect them directly to your data, and share them with interactive dashboards and beautiful visuals.