Hello,
This is my first post to this forum, so thank you in advance to all the experts here. I have a prototype that hides and unhides columns in my spreadsheet based on inputs. However, I expect the combinations to grow thus requiring me to develop a more scalable solution than the one I have below. Any assistance is greatly appreciated. My current code is listed below.
Private Sub Worksheet_Change(ByVal Target As Range)
If Range("B1").Value = "USA" And Range("B2").Value = "ABC" Then
Columns("K:O").EntireColumn.Hidden = True
Columns("K").EntireColumn.Hidden = False
Else
If Range("B1").Value = "USA" And Range("B2").Value = "CBA" Then
Columns("K:O").EntireColumn.Hidden = True
Columns("L").EntireColumn.Hidden = False
Else
If Range("B1").Value = "Benelux" And Range("B2").Value = "STG" Then
Columns("K:O").EntireColumn.Hidden = True
Columns("M").EntireColumn.Hidden = False
Else
If Range("B1").Value = "Germany" And Range("B2").Value = "SBG" Then
Columns("K:O").EntireColumn.Hidden = True
Columns("N").EntireColumn.Hidden = False
Else
If Range("B1").Value = "Canada" And Range("B2").Value = "STG" Then
Columns("K:O").EntireColumn.Hidden = True
Columns("O").EntireColumn.Hidden = False
Else
If Range("B1").Value = "" And Range("B2").Value = "" Then
Columns("K:O").EntireColumn.Hidden = True
End If
End If
End If
End If
End If
End If
End Sub
Bookmarks