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 is their a workaround that accomplishes the same task without having to manually change the column width?
Thanks...
2 Replies
- MobeeDickCopper ContributorHighlight the entire column at the top, then Double tap (double click). It will automatically "right size"
- Haytham AmairahSilver 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 SubAfter 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