Hope someone can help...
I have a dropdown list of employee names to filter a matrix-style spreadsheet. On selection, all columns except the selected are hidden.
My problem is that every time I add a new employee, I have to modify the code to match the name to a specific column. I need code that will search the columns in a range for the value from the dropdown, then hide all other columns. Here is a shot of my current code:
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Range("$E$2").Value
Case Is = "ALL OPERATORS"
Columns("F:AW").EntireColumn.Hidden = False
Range("Table12LL").Select
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
Range("A1").Select
Case Is = "Al Castro"
Columns("F:F").EntireColumn.Hidden = False
Columns("G:AW").EntireColumn.Hidden = True
Case Is = "Austin Furrow"
Columns("G:G").EntireColumn.Hidden = False
Columns("F:F").EntireColumn.Hidden = True
Columns("H:AW").EntireColumn.Hidden = True
Case Is = "Bobby Dykman"
I have a dropdown list of employee names to filter a matrix-style spreadsheet. On selection, all columns except the selected are hidden.
My problem is that every time I add a new employee, I have to modify the code to match the name to a specific column. I need code that will search the columns in a range for the value from the dropdown, then hide all other columns. Here is a shot of my current code:
Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Range("$E$2").Value
Case Is = "ALL OPERATORS"
Columns("F:AW").EntireColumn.Hidden = False
Range("Table12LL").Select
On Error Resume Next
ActiveSheet.ShowAllData
On Error GoTo 0
Range("A1").Select
Case Is = "Al Castro"
Columns("F:F").EntireColumn.Hidden = False
Columns("G:AW").EntireColumn.Hidden = True
Case Is = "Austin Furrow"
Columns("G:G").EntireColumn.Hidden = False
Columns("F:F").EntireColumn.Hidden = True
Columns("H:AW").EntireColumn.Hidden = True
Case Is = "Bobby Dykman"