Forum Discussion
tomc72
Aug 10, 2020Brass Contributor
Column width
I would like to know if I can use a formula to set a column width that depends on the width of the row number. For example: If the row number exceeds 999, then the row number column width increases i...
- Aug 23, 2020
tomc72 , as workaround, you can hide the headings by going to VIEW tab and unchecking the Headings under "Show" as shown in below image. Then on scrolling down, the columns won't shift to the right. But compromise is, you cannot see row numbers (1,2,3...)or column headers (A,B,C...).
NikolinoDE
Aug 10, 2020Platinum Contributor
Many roads lead to Rome ... with Excel there are many more roads to a solution.
With a simple formula:
=CELL("width",D1)
With VBA:
Sub Column_width()
Sheets("Tabelle1").Activate
Range("S:NH").EntireColumn.ColumnWidth = 15
End Sub
I would be happy to know if I could help.
Nikolino
I know I don't know anything (Socrates)
* Kindly Mark and Vote this reply if it helps please, as it will be beneficial to more Community members reading here.
* Beware of scammers posting fake support numbers here.
NikolinoDE
Aug 10, 2020Platinum Contributor
If it had to automatically adapt its content.
Sub Column_width()
Sheets("Tabelle1").Activate
Columns("C:D").EntireColumn.AutoFit
End Sub
Sub Column_width()
Sheets("Tabelle1").Activate
Columns("C:D").EntireColumn.AutoFit
End Sub