View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default collapse an expand rows using VB

Hi there

The code below works fine however I don't know if it is exactly what you
need. Because when a Row is set to 0 you cannot access it anymore except if
the height is changed again manually.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 3 Then
If Target.Value = 100 Then
Rows(Target.Row).RowHeight = 0
Else
Rows(Target.Row).RowHeight = 17
End If
End If
End Sub

Kind regards,
Alex

------------------------------------
Excel-Spezialist
www.excelspezialist.ch
------------------------------------

"soinx" schrieb im Newsbeitrag
...
I want to collapse and expand certain rows in a worksheet. The rows that
should be collapsed (height=0) or expanded (height=17) are determined by
the
value of a certain cell in this row. In this case it is the value of the
cell
in the C-column that will termine whether or not the row height should be
set
to 0 or 17. If the cell value is "100", the height should be set to 0, and
if
the cell value is different from 100 the height should be set to 17.

I am a bit lost here. Can anyone help me with this?