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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top