Data Import & Export

Set a Default Column Width for CSV Files in Excel 2016

Ayan MasoodAyan Masood Nov 25, 2026 870 views

Question details

Set a consistent column width when opening large CSV files in Excel 2016.

Set a Default Column Width for CSV Files in Excel 2016
Product
Microsoft Excel 2016
Device & OS
not provided
Scenario
The user repeatedly opens large CSV files and wants to avoid resizing narrow columns each time.
Observed behavior
CSV columns open narrow, and Excel does not offer a global default column-width setting specifically for CSV files.
Before you start

Choose a column width to use, such as 20, and make sure macros are permitted by your organization's security settings. CSV files store data rather than Excel formatting, so column widths will not be retained when you save as CSV.

Solution 1Recommended

Open and Format CSV Files with a Reusable VBA Macro

Use this approach to apply the same width whenever you open a CSV through the macro.

Store the macro in the Personal Macro Workbook so it is available in future Excel sessions. The macro must be run to open each CSV; it does not change how files open when you double-click them.

1
Create the Personal Macro Workbook

In Excel, select View > Macros > Record Macro. Under Store macro in, choose Personal Macro Workbook, select OK, and then select View > Macros > Stop Recording.

2
Add the CSV macro

Open the VBA editor from Developer > Visual Basic. In the Project window, select VBAProject (PERSONAL.XLSB), choose Insert > Module, and paste: Sub OpenCSVWithWidth() Dim filePath As Variant Dim csvBook As Workbook filePath = Application.GetOpenFilename("CSV Files (*.csv),*.csv") If VarType(filePath) = vbBoolean Then Exit Sub Set csvBook = Workbooks.Open(Filename:=CStr(filePath)) csvBook.Worksheets(1).Columns.ColumnWidth = 20 End Sub

3
Choose your preferred width

In the VBA editor, replace 20 in the ColumnWidth line with the width you want. Close the editor and save changes to the Personal Macro Workbook when Excel prompts you.

4
Open a CSV through the macro

Select View > Macros > View Macros, choose OpenCSVWithWidth, and select Run. Pick a CSV file in the file dialog; Excel opens it and applies the selected width.

Open and Format CSV Files with a Reusable VBA Macro
Keep formatting in a workbook: Use File > Save As and choose Excel Workbook (*.xlsx) if you need to retain the column widths. Saving as CSV will not preserve them.
Free Microsoft Office alternative

Work with CSV Files in WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar interface for opening and editing spreadsheets. It supports common Excel formats for easier migration, although it does not change Excel's CSV defaults or make CSV files retain formatting.

Open CSV files and adjust column widths in a spreadsheet interface.Work with Microsoft Excel formats, including XLSX and XLS.Use familiar spreadsheet tools when moving from Microsoft Office.Get a free, lightweight office suite for everyday document work.
microsoft office alternative - wps office

Frequently Asked Questions

Why do my column widths disappear when I save a CSV?

CSV stores text data, not worksheet formatting. To retain column widths, choose File > Save As and save a copy as an Excel Workbook (*.xlsx).

Will an Excel template change the width of every CSV I open?

No. A custom template can set widths for new workbooks or worksheets, but opening a CSV directly does not automatically apply that template.

Where is the macro stored so I can use it again?

Store it in the Personal Macro Workbook, PERSONAL.XLSB. Create that workbook through View > Macros > Record Macro, and save its changes when Excel prompts you.

Can the macro format a CSV that is already open?

The provided macro opens a CSV selected in its file dialog. For an already open file, use Home > Format > Default Width or select columns and use Home > Format > Column Width.