PDA

View Full Version : conditional hiding of Rows



K. Georgiadis
10-04-2006, 07:23 AM
I have done this successfully with toggle switches but I am having a mental block when linking it to a variable cell:

In a workbook containing multiple sheets, this applies to a specific worksheet only;


Cell G17 is a variable, expressed in $ per pound
Upon entering 0 (zero) in G17, I want to hide Rows 17:19 and Row 54
If the value entered in G17 is anything above zero (there will be no negative numbers), I want the above mentioned rows to remain unhiddenYour help is greatly appreciated.

Erdin? E. Ka
10-04-2006, 07:43 AM
Hi,


Private Sub Worksheet_Change(ByVal Target As Range)

If [G17] < 0 Then [G17] = ""

If Target.Row = 17 And Target.Column = 7 Then
Select Case Target.Value
Case 0
Range("17:19,54:54").EntireRow.Hidden = True
Case Is > 0
Range("17:19,54:54").EntireRow.Hidden = False
End Select
End If
End Sub

K. Georgiadis
10-04-2006, 07:52 AM
Perfect! Thanks...

Bob Phillips
10-04-2006, 08:21 AM
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$G$17" Then
Range("17:19,54:54").EntireRow.Hidden = Target.Value = 0
End If
End Sub

Erdin? E. Ka
10-04-2006, 08:32 AM
Perfect! Thanks...
Not at all,

xld, your code is cool.

K. Georgiadis
10-04-2006, 10:05 AM
xld's code works perfectly too! Thanks to both.:beerchug: