Forum Discussion
How to permanently fix column width
Each time I open up my excel file, the columns revert back to a smaller size. I have to widen the columns each time that I open the file. How do I permanently expand the file and save it to avoid having to widen the columns each time I re-open the file? Thank you
- If you are using Office 2019 and working with a CSV file, the column width settings cannot be directly saved within the CSV file itself. However, you can use a workaround by following these steps: - Open the CSV file in Excel.
- Adjust the column widths as desired by dragging the column dividers or using the AutoFit feature to fit the content.
- Select all the cells in the worksheet by clicking the "Select All" button at the top left corner of the worksheet (or pressing Ctrl+A).
- Right-click on any of the selected cells and choose "Copy" from the context menu.
- Create a new Excel workbook by clicking "File" > "New Workbook" or pressing Ctrl+N.
- In the new workbook, right-click on cell A1 and choose "Paste" > "Keep Source Formatting" or press Ctrl+Alt+V. This will paste the content, including the adjusted column widths, from the CSV file into the new workbook.
- Finally, save the new workbook as an Excel file (.xlsx) by clicking "File" > "Save As" and choosing a location on your computer.
 - By following these steps, you will have a new Excel file with the adjusted column widths saved. Whenever you open this file, the columns should remain the same width as you set them. - Please note that this workaround involves copying the content from the CSV file into a new Excel file. Any formulas, formatting, or data validation rules that were present in the original CSV file may not be preserved in the new Excel file. 
5 Replies
- NikolinoDEPlatinum ContributorSince there is no information about which Excel version it is, which operating system or storage medium. I'm assuming it's Excel 2016 and Windows 10...But it also fits other versions. Why? because there are no details! Welcome to your Excel discussion space! Suggested solutions: To permanently fix the column width in Excel and ensure that it remains the same when you reopen the file, you can follow these steps: - Open your Excel file.
- Select the column or columns that you want to adjust the width for. To select multiple columns, hold down the Ctrl key while clicking on each column header.
- Once the columns are selected, right-click on any of the selected column headers and choose "Column Width" from the context menu.
- In the Column Width dialog box, enter the desired width for the columns and click "OK". You can specify the width in characters or pixels.
- After adjusting the column width, go to the "File" tab in the Excel ribbon and click on "Save" or press Ctrl+S to save your changes.
 By following these steps, the column width settings will be saved with the Excel file, and when you reopen it, the columns should remain the same width as you set them. Note: If you want to apply the same column width settings to multiple Excel files, you can create a template file with the desired column width and use it as a basis for new files. Simply save the template file and use it as a starting point whenever you need to create a new Excel file. How to AutoFit in Excel: adjust columns and rows to match data size How to change column width and AutoFit columns in Excel Option with VBA code: Option Explicit Sub SetColumns() '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' Purpose: Autofit columns but make sure not less than default minimum width ' Assumption: The preferred minimum column width has been previously set, so the ' procedure should make the column wider if required, but not skinnier '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Dim rng As Range ' cells in heading range Dim sngWidth As Single ' default width of column For Each rng In Range(Range("A1"), Range("IV1").End(xlToLeft)) sngWidth = Columns(rng.Column).ColumnWidth rng.EntireColumn.AutoFit ' reset column if it is skinnier than the original width If Columns(rng.Column).ColumnWidth < sngWidth Then Columns(rng.Column).ColumnWidth = sngWidth End If Next rng End Sub ' Code from http://www.vbaexpress.comHow to use: - Open Excel
- Open the VBE window by pressing [Alt-F11]
- Select Insert | Module
- Copy the code above and paste it into the module
- Press [Alt-F4] to close the VBE window
 Test the code: - Copy all data rows in the sheet "Data"
- Paste the data into cell A2 of the "Template" sheet
- Select Tools | Macro | Macros
- Double-click on "SetColumns"
- Check that all data is displayed correctly, and no headings have strange text wrapping
- Select column D on the "Template" sheet
- Select Format | Column | Width
- Type "11" and press [Enter]
- Select Tools | Macro | Macros
- Double-click on "SetColumns"
- Note the width of column D
 Sample File:Insert - nzingha417Copper ContributorNikolinoDE I am using office 2019 and it is a csv file. Thank you. - NikolinoDEPlatinum ContributorIf you are using Office 2019 and working with a CSV file, the column width settings cannot be directly saved within the CSV file itself. However, you can use a workaround by following these steps: - Open the CSV file in Excel.
- Adjust the column widths as desired by dragging the column dividers or using the AutoFit feature to fit the content.
- Select all the cells in the worksheet by clicking the "Select All" button at the top left corner of the worksheet (or pressing Ctrl+A).
- Right-click on any of the selected cells and choose "Copy" from the context menu.
- Create a new Excel workbook by clicking "File" > "New Workbook" or pressing Ctrl+N.
- In the new workbook, right-click on cell A1 and choose "Paste" > "Keep Source Formatting" or press Ctrl+Alt+V. This will paste the content, including the adjusted column widths, from the CSV file into the new workbook.
- Finally, save the new workbook as an Excel file (.xlsx) by clicking "File" > "Save As" and choosing a location on your computer.
 By following these steps, you will have a new Excel file with the adjusted column widths saved. Whenever you open this file, the columns should remain the same width as you set them. Please note that this workaround involves copying the content from the CSV file into a new Excel file. Any formulas, formatting, or data validation rules that were present in the original CSV file may not be preserved in the new Excel file.