Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Hide entire rows if 3 cols have a dash (w2000, office xp)

    In excel i need a macro to hide any rows that have 3 dashes (hyphens in them). For instance, my range includes columns A, B, C, and D. I need a macro that if B AND C AND D have a hyphen in them that row needs to be hidden. Thank you for the help.

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

    Re: Hide entire rows if 3 cols have a dash (w2000, office xp)

    Try the following and adapt it to your needs:

    Dim rng As Range
    Dim i As Integer
    Set rng = Selection
    ' Loop through the rows
    For i = 1 To rng.Rows.Count
    ' Test cells in 2nd, 3rd and 4th column
    If rng.Cells(i, 2) = "-" And rng.Cells(i, 3) = "-" And rng.Cells(i, 4) = "-" Then
    ' If all three cells contain a hyphen (only), hide entire row
    rng.Cells(i, 1).EntireRow.Hidden = True
    End If
    Next i

  3. #3
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Illinois
    Posts
    552
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Hide entire rows if 3 cols have a dash (w2000, office xp)

    ok, thank you so much

Posting Permissions

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