Link to home
Start Free TrialLog in
Avatar of Rick Norris
Rick Norris

asked on

Another Hide/Show Excel rows question

I have reviewed questions answered concerning hiding and showing rows in Excel; however, I  have not quite found something that I could modify to obtain the results I need.

If the experts here would take  a look at my attached spreadsheet, it gives a very detailed example of what I am needing.   Any and all help is greatly appreciated.

Thanks,
Example.xlsx
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

I assume the rows to be hidden are on the Decision Matrix sheet. Given that the listbox says Company 1 is that the only company that is affected?

Is a VBA solution acceptable?
In any case try this macro.

Sub ShowHide()
Dim strListBoxValue As String
Dim rngFound As Range
Dim lngRow As Long

strListBoxValue = "Company 1"
Set rngFound = Columns("A:A").Find(What:=strListBoxValue, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)

For lngRow = rngFound.Row + 1 To ActiveSheet.UsedRange.Rows.Count + 1
    If Cells(lngRow, "B") = "" Then
        Exit For
    End If
    If UCase(Cells(lngRow, "D")) = "X" Then
        Cells(lngRow, "A").EntireRow.Hidden = True
    Else
        Cells(lngRow, "A").EntireRow.Hidden = False
    End If
Next

End Sub

Open in new window

Avatar of Rick Norris
Rick Norris

ASKER

Martin:

Rows to be dynamically hidden/shown are on the "Example" sheet.

Please review that sheet....  

Thanks,
Please review that sheet....
I did and my code hides Criteria 2 for Company 1. What should it do differently?
If you could attach the spreadsheet you are working with would be appreciated.....  When I paste in code I get an error....

When Company changes on the "EXAMPLE" sheet, then DECISION MATRIX tab is evaluated to determine what rows to hide or show on the EXAMPLE sheet.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Martin:

Thanks for the workbook....  Works for what I need....  Now I just need to expand on your work for my real world problem.

Thanks again!!
Let me know (here if you like) if you need help. In any case you're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2015