+ Reply to Thread
Results 1 to 2 of 2

need a switch-How Do I Hide A Row (if a condition is true) using a Macro ?

  1. #1
    Anthony Fantone
    Guest

    need a switch-How Do I Hide A Row (if a condition is true) using a Macro ?

    I'm using MS Office Excel 2003.

    I have a spreadsheet with a series of cells that require an input of (Y)es,
    (N)o or (H)ide. If the user enters an "H" for hide I want that entire row to
    Hide. Is there a Macro I can use to make this happen.

    Also, I would need a switch at the top of the spreadsheet that would allow a
    user to enter a "U" for "Unhide" so that all hidden rows could be "U"nhidden
    and visable again. Is there a Macro I can use to make this happen also ?

    Thank You for your help.

  2. #2
    Bob Phillips
    Guest

    re: need a switch-How Do I Hide A Row (if a condition is true) using a Macro ?

    This works on H1:H10, adjust to suit

    Private Sub Worksheet_Change(ByVal Target As Range)

    On Error GoTo ws_exit:
    Application.EnableEvents = False
    If Not Intersect(Target, Me.Range("H1:H10")) Is Nothing Then
    With Target
    If .Value = "H" Then
    .EntireRow.Hidden = True
    End If
    End With
    End If

    ws_exit:
    Application.EnableEvents = True
    End Sub

    'This is worksheet event code, which means that it needs to be
    'placed in the appropriate worksheet code module, not a standard
    'code module. To do this, right-click on the sheet tab, select
    'the View Code option from the menu, and paste the code in.



    --
    HTH

    Bob Phillips

    "Anthony Fantone" <Anthony [email protected]> wrote in
    message news:[email protected]...
    > I'm using MS Office Excel 2003.
    >
    > I have a spreadsheet with a series of cells that require an input of

    (Y)es,
    > (N)o or (H)ide. If the user enters an "H" for hide I want that entire row

    to
    > Hide. Is there a Macro I can use to make this happen.
    >
    > Also, I would need a switch at the top of the spreadsheet that would allow

    a
    > user to enter a "U" for "Unhide" so that all hidden rows could be

    "U"nhidden
    > and visable again. Is there a Macro I can use to make this happen also ?
    >
    > Thank You for your help.




+ 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