+ Reply to Thread
Results 1 to 4 of 4

Conditional Hide Rows Macro

  1. #1
    cchubba
    Guest

    Conditional Hide Rows Macro

    I want a macro to do a conditional hide automatically based on another
    value in another cell.

    For example:

    If Cell A1 = "Yes" then hide rows 20:23
    If Cell A1 = "No" then do not hide rows 20:23


    The closest thing i can find is the below example which hides the row
    based on the value (in the same row) in column T




    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Select Case Range("T" & Target.Row).Value
    Case Is = "Y"
    Target.EntireRow.Hidden = True
    Case Is = "N"
    Target.EntireRow.Hidden = False
    End Select
    End Sub


  2. #2
    Forum Contributor colofnature's Avatar
    Join Date
    05-11-2006
    Location
    -
    MS-Off Ver
    -
    Posts
    301
    Try this:

    Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    Select Case ucase(Range("a1").Value)
    case "YES"
    [20:23].entirerow.hidden = true
    case else
    [20:23].entirerow.hidden = false
    End Select
    End Sub


    Col

  3. #3
    Don Guillett
    Guest

    Re: Conditional Hide Rows Macro


    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$A$1" Then Exit Sub

    If UCase(Target) = "Y" Then
    Rows("20:23").Hidden = True
    Else
    Rows("20:23").Hidden = False
    End If
    End Sub

    another idea just assigned to a button
    sub hideunhidecolg()
    Columns("g").EntireColumn.Hidden = Not Columns("g").EntireColumn.Hidden
    end sub
    --
    Don Guillett
    SalesAid Software
    [email protected]
    "cchubba" <[email protected]> wrote in message
    news:[email protected]...
    >I want a macro to do a conditional hide automatically based on another
    > value in another cell.
    >
    > For example:
    >
    > If Cell A1 = "Yes" then hide rows 20:23
    > If Cell A1 = "No" then do not hide rows 20:23
    >
    >
    > The closest thing i can find is the below example which hides the row
    > based on the value (in the same row) in column T
    >
    >
    >
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > Select Case Range("T" & Target.Row).Value
    > Case Is = "Y"
    > Target.EntireRow.Hidden = True
    > Case Is = "N"
    > Target.EntireRow.Hidden = False
    > End Select
    > End Sub
    >




  4. #4
    cchubba
    Guest

    Re: Conditional Hide Rows Macro


    colofnature wrote:
    > Try this:
    >
    > Private Sub Worksheet_Change(ByVal Target As Excel.Range)
    > Select Case ucase(Range("a1").Value)
    > case "YES"
    > [20:23].entirerow.hidden = true
    > case else
    > [20:23].entirerow.hidden = false
    > End Select
    > End Sub
    >
    >
    > Col
    >
    >
    > --
    > colofnature
    > ------------------------------------------------------------------------
    > colofnature's Profile: http://www.excelforum.com/member.php...o&userid=34356
    > View this thread: http://www.excelforum.com/showthread...hreadid=548938


    That works great! Thanks


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1