Consulting

Results 1 to 6 of 6

Thread: conditional hiding of Rows

  1. #1

    conditional hiding of Rows

    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;

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

  2. #2
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location
    Hi,

    [vba]
    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
    [/vba]
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

  3. #3
    Perfect! Thanks...

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    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
    [/vba]

  5. #5
    VBAX Tutor Erdin? E. Ka's Avatar
    Joined
    Sep 2006
    Location
    Bursa
    Posts
    264
    Location
    Quote Originally Posted by K. Georgiadis
    Perfect! Thanks...
    Not at all,

    xld, your code is cool.
    Erdin? E. Kara?am | Loves from Bursa city in Republic of T?rkiye

  6. #6
    xld's code works perfectly too! Thanks to both.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •