AutoFit

P

Patrick C. Simonds

Is there any way to use the code below and still maintain a minimum row
height of 27?

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

Target.EntireRow.AutoFit

End Sub
 
G

Gary Keramidas

there may be a way, but i don't know it:

Sub test()
Dim r As Long
With ActiveCell.EntireRow
r = Application.Max(.AutoFit, 27)
..RowHeight = r
End With
End Sub
 
P

Patrick C. Simonds

I actually came up with a work around.

I needed my rows to have a minimum height of 23, but when I set the row
heights to that the autofix would not increase the row height to account for
those rows where text wrapping took place. So I created a hidden column and
put a number in each row and selected a font size which would produce a row
height that I needed. It worked great.
 
P

Per Jessen

This should do it:

Private Sub Worksheet_Change(ByVal Target As Range)

Target.EntireRow.AutoFit
If Target.RowHeight < 27 Then Target.RowHeight = 27

End Sub

Regards,
Per
 

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

Top