ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AutoFit (https://www.excelbanter.com/excel-programming/415761-autofit.html)

Patrick C. Simonds

AutoFit
 
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


NoodNutt

AutoFit
 
Target.Rows.AutoFit



Gary Keramidas

AutoFit
 
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

--


Gary


"Patrick C. Simonds" wrote in message
...
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




NoodNutt

AutoFit
 
Oops!

Try this

Target.Rows.RowHeight = 27

HTH



Patrick C. Simonds

AutoFit
 
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.


"NoodNutt" wrote in message
...
Oops!

Try this

Target.Rows.RowHeight = 27

HTH



Per Jessen

AutoFit
 
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

"Patrick C. Simonds" skrev i meddelelsen
...
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.


"NoodNutt" wrote in message
...
Oops!

Try this

Target.Rows.RowHeight = 27

HTH





All times are GMT +1. The time now is 02:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com