Settign a Maximum and Minimum Row Height

  • Thread starter Thread starter Stephen
  • Start date Start date
S

Stephen

I'm trying to format my spreadsheet to accomadate a minimum row height, but
be able to expand to my largest section.

Eg. I want to have my minimum row height as 51, but if the text requires
more space then that, it will allow the cell to expand to that height.
 
You will need VBA code to do that; something like this maybe...

Sub AutoFitRowHeightWhenNecessary()
Dim R As Range
Dim CurrentHeight As Double
Const MinRowHeight As Double = 51
On Error GoTo Whoops
Application.ScreenUpdating = False
For Each R In Worksheets("Sheet1").UsedRange.Rows
R.AutoFit
If R.RowHeight < MinRowHeight Then
R.RowHeight = MinRowHeight
End If
Next
Whoops:
Application.ScreenUpdating = True
End Sub
 
Back
Top