Forum Discussion
HenryVIII
Jan 27, 2019Copper Contributor
Automatic column sizing
Is there a function key that will allow one to paste new column headings over existing column headings and have the system automaitically adjust the column width to match the new headings? If not ...
Haytham Amairah
Jan 27, 2019Silver Contributor
Hi Henry,
You need to a special solution using a VBA code.
Hover the Mouse over the worksheet tab, right-click, and select (View Code).
Then copy and paste the below code into the worksheet code module.
Private Sub Worksheet_Change(ByVal Target As Range)
Cells.Columns.AutoFit
End Sub
After that, save the workbook as (*.xlsm) to retain the code in it.
Please note that this code applies only to the sheet in which this code is saved.
Hope that helps