Is there a way to control the height of a row via an excel function?

  • Thread starter Thread starter lseyer
  • Start date Start date
L

lseyer

I'm trying to control the height of a row determined by the contents o
a cell...

I can't seem to find a function or command that is available to me t
allow this.

Alternatively, is there a way that I can 'hide' or 'unhide' a row base
on a cell's contents?

Best to you!

Larry Seye
 
The only way I know of controling the height of a row is
by using the Format/Row/Autofit, it might be possible uing
VBA, try posting the question under programing see what
answer you get. However, for the second part of your
question, you can fake the hide unhide feature by using
Conditional Forming and selecting the font color as white.
For example you can enter. If Cell Value is less than 10
format as Font as White.

Chalie O'Neill
 
I can see how hiding a row makes sense based on a value in that row.

But unhiding a row seems like a problem. How would the value change so that it
could change--maybe the result of a formula?

If changed by typing, right click on the worksheet tab that should have this
behavior and select view code. Then paste this into the code window.

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

If lcase(Target.Value) = "hide me" Then
Target.EntireRow.Hidden = True
Else
Target.EntireRow.Hidden = False
End If

End Sub

Adjust the range (I used column A). And adjust the value to check for.

If the cell changes because of a calculation, you could use this:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

If Target.Value = "Hide me" Then
Target.EntireRow.Hidden = True
Else
Target.EntireRow.Hidden = False
End If

End Sub

This is also a worksheet event. Use the same rightclick on the worksheet tab to
set this up.

======
Personally, I think I'd apply Data|Filter|autofilter.

It wouldn't be automatic, but I could use it whenever I wanted and I could use
it for many more things.
 

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