Automatically change row height?

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
 
M

muddan madhu

Private Sub worksheet_change(ByVal target As Range)
Set target = Rows("2:2")
If Range("A1").Value <> "" Then
target.AutoFit
End If
End Sub
 
A

AltaEgo

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
 

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