inverse of ShrinkToFit

  • Thread starter Thread starter Agoston Bejo
  • Start date Start date
A

Agoston Bejo

Is there a property for the Range object that does the opposite of
ShrinkToFit? I mean, something like CellExpandsToFit, i.e. the cell size /
row width / column width is adjusted automatically so that the whole text in
it will be visible.

Is there any other ways to accomplish the same effect? E.g. iterate over all
the columns, determine if the texts fit the cells everywhere and if not, set
it to wider.
For that I should be able to determine if the whole text is visible in a
cell.

Thx
 
You could use a worksheet event that adjusts the column widths.

If any of your cells could change because of a calculation, you could use this:

Option Explicit
Private Sub Worksheet_Calculate()
Me.UsedRange.Columns.AutoFit
End Sub

Right click on the worksheet tab that should have this behavior. Select view
code and paste this into the code window.

But you'll notice that you've lost the Edit|Undo (for the most part).
 
Back
Top