View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gordon[_2_] Gordon[_2_] is offline
external usenet poster
 
Posts: 211
Default Hide Rows based on value of a cell

Hi...

The value 1 fires in cell a1 and nothing happens. I should add that the 1 is
derived from a formula, does that make a difference.

This is the code currently in the sheet properties. Might something clash?

Private Sub Worksheet_Activate()
ActiveSheet.ScrollArea = "$a$1:$s$30"
End Sub
Private Sub Worksheet_Calculate()
Dim sh As Worksheet
SheetArray = Array("R", "A", "B", "Ba", "Rs", "Co", _
"Bf", "Bs", "Pa", "Pt", "Pa", "Ea", "Bar", "Ds", "Sp", "df")
Set sh = Worksheets("SETUP")
For sht = LBound(SheetArray) To UBound(SheetArray)
With Sheets(SheetArray(sht))
If sh.Range("R4").Value = 0 Then
.Visible = xlSheetHidden
ElseIf sh.Range("R4").Value = 1 Then
.Visible = xlSheetVisible
End If
End With
Next
End Sub


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
Application.EnableEvents = False
If Target.Value = 0 Then
Rows("1:19").EntireRow.Hidden = True
Else
Rows("1:19").EntireRow.Hidden = False
End If
Application.EnableEvents = True
End If
End Sub



"Mike H" wrote:

Gordon,

Right click your sheet tab, view code and paste this in.
Enter 1 in A1 hides the rows anything else makes them visible,

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Target.Address = "$A$1" Then
Application.EnableEvents = False
If Target.Value = 1 Then
Rows("8:19").EntireRow.Hidden = True
Else
Rows("8:19").EntireRow.Hidden = False
End If
Application.EnableEvents = True
End If
End Sub

Mike

"Gordon" wrote:

Hi...

If I enter 1 into cell A1 I want to automatically hide rows 8-19. Is this
possible?

Cheers

G