I have a workbook that has 54 sheets (a TOC, Setup, and a tab for 52 weeks).
In the Setup sheet I have 20 products setup and I have a Y/N column next to each product to determine if that product is being used or not. What I want is, if the product has an N next to it and it is not being used, then i want to hide all the rows associated with that product in the 52 weeks. If I come in and change the N to a Y, then I want it to unhide all the rows associated with the product in the 52 weeks.
You can see in the code what I have been testing out, it's inside the Setup worksheet. It works, but I don't want to be creating this line of code for 52 separate tabs and for 20 different products. What is a better solution?
Thanks!
In the Setup sheet I have 20 products setup and I have a Y/N column next to each product to determine if that product is being used or not. What I want is, if the product has an N next to it and it is not being used, then i want to hide all the rows associated with that product in the 52 weeks. If I come in and change the N to a Y, then I want it to unhide all the rows associated with the product in the 52 weeks.
You can see in the code what I have been testing out, it's inside the Setup worksheet. It works, but I don't want to be creating this line of code for 52 separate tabs and for 20 different products. What is a better solution?
Thanks!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
' Hiding/Unhiding Product1
If Range("B3").Value = "N" Then
Sheet3.Rows("10:13").EntireRow.Hidden = True
Sheet4.Rows("10:13").EntireRow.Hidden = True
Else
Sheet3.Rows("10:13").EntireRow.Hidden = False
Sheet4.Rows("10:13").EntireRow.Hidden = False
End If
' Hiding/Unhiding Product20
If Range("B22").Value = "N" Then
Sheet3.Rows("85:88").EntireRow.Hidden = True
Sheet4.Rows("85:88").EntireRow.Hidden = True
Else
Sheet3.Rows("85:88").EntireRow.Hidden = False
Sheet4.Rows("85:88").EntireRow.Hidden = False
End If
End Sub