View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
jack[_2_] jack[_2_] is offline
external usenet poster
 
Posts: 44
Default Hiding / unhiding rows based on change of a cell

I can't seem to get the following code to work. I want to hide / unhide a
series of rows on sheet1 based on the value in a cell in sheet2. Once I
understand how to get it to work, I want to expand it to approx. 40 cells on
sheet2 to hide / unhide groups of rows on sheet1.
Do I put the code in sheet1, sheet2 or the workbook?
Any ideas to steer me in the right direction?
Thanks


Private Sub Worksheet_Change(ByVal Target As Range)
If Range("sheet2!$I$51") = "" Then
Range("sheet1!$A$641:$A$653").EntireRow.Hidden = True
Else
Range("sheet1!$A$641:$A$653").EntireRow.Hidden = False
End If
If Range("sheet2!$I$52") = "" Then
Range("sheet1!$A$654:$A$666").EntireRow.Hidden = True
Else
Range("sheet1!$A$654:$A$666").EntireRow.Hidden = False
End If
End Sub