Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    250
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hidding rows based on value of cell (2003)

    Hello,

    I am trying to write a macro that uses a value from a cell list coming from a validation list to hide some rows. For example, cell a5 has the list when I select it. I want rows 10 through 12 to be hidden. Any help would be great.

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hidding rows based on value of cell (2003)

    Sorry, I do not understand what you want to do. It sounds like cell A5 uses data validation to select a value from a list of values. Do you want to hide rows 10 through 12 when some particular value is selected from the list? If so, what value? Do you want this to happen automatically when the selection is made from the list, or when something else happens?
    Legare Coleman

  3. #3
    3 Star Lounger
    Join Date
    Dec 2006
    Posts
    250
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hidding rows based on value of cell (2003)

    Correct. Cell 5A uses data validaton to select a value from a list of values. The values from the list are company1, company2, company3, and company4. the name for the list is company. When it selects company4, I want to be able to hide rows 10 through 12. I hope this helps.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hidding rows based on value of cell (2003)

    Right-click the sheet tab and select 'Show Code' from the popup menu.
    Enter or paste the following code into the module that appears:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Range("A5"), Target) Is Nothing Then
    Application.EnableEvents = False
    Me.Range("A10:A12").EntireRow.Hidden = (LCase(Me.Range("A5")) = "company4")
    Application.EnableEvents = True
    End If
    End Sub

    See attached workbook.
    Attached Files Attached Files

Posting Permissions

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