Automatically change row height?

  • Thread starter Thread starter Lostguy
  • Start date Start date
L

Lostguy

Hello.

The user types text stuff in A1. If there is no text, the row height
for A2 is zero/minimal. If there is text, A2's row height autofits to
that text. Some users enter more text than others, so A2's height has
to grow or shrink depending on what is in A1. The formula in A2 is IF
(A1="","",A1&", "&F16)


Is this possible without VBA? If not, does anyone have any good code
for this?

Thanks!

VR/Lost
 
Private Sub worksheet_change(ByVal target As Range)
Set target = Rows("2:2")
If Range("A1").Value <> "" Then
target.AutoFit
End If
End Sub
 
Right-click on your sheet tab and paste the following code into the module

Private Sub Worksheet_Change(ByVal Target As Range)
Set isect = Application.Intersect(Range("A1"), Target)
If Not isect Is Nothing Then
If Range("A1") & "" = "" Then
Rows("2:2").RowHeight = 0
Else
Rows("2:2").EntireRow.AutoFit
End If
End If
End Sub
 
Back
Top