Hi,
I have a master table with the following structure:
I want to Unhide Sheet "Legal" to reveal details about Legal Fee - only when the relevant criteria is met and Column C reflects "Y". I need the sheets where Column C is "N" to be hidden, i.e. Sheet "XYZ Admin".
I am using the following code assigned to a click button. As the Y/N in the table constantly changes, i will need each click to hide/unhide relevant sheets based on recent data.
However, I have more than 200 rows with items with unique work sheet name. Instead of replicating and manually editing the formula for 200 times, is there a way that i could make my formula dynamic by referencing to the cell values as sheet name?
Please note that i have other sheets with key data to be shown in the same workbook but not subject to the above criteria.
I am very new to VBA and only start working on it for a few days. Thanks for all your help!
I have a master table with the following structure:
Row 1 | Column A (Item) | Column B (Corresponding Sheet Name) | Column C (To unhide corresponding sheet (based on IF statement results of other values in the table)) |
Row 2 | Legal fee | Legal | Y |
Row 3 | Admin fee for GHI | GHI Admin | Y |
Row 4 | Admin fee for XYZ | XYZ Admin | N |
I want to Unhide Sheet "Legal" to reveal details about Legal Fee - only when the relevant criteria is met and Column C reflects "Y". I need the sheets where Column C is "N" to be hidden, i.e. Sheet "XYZ Admin".
I am using the following code assigned to a click button. As the Y/N in the table constantly changes, i will need each click to hide/unhide relevant sheets based on recent data.
VBA Code:
Sub Hide_Sheet()
If [C2] = "Y" Then
Sheets("Legal").Visible = True
Else
Sheets("Legal").Visible = False
End If
If [C3] = "Y" Then
Sheets("GHI Admin").Visible = True
Else
Sheets("GHI Admin").Visible = False
End If
End Sub
However, I have more than 200 rows with items with unique work sheet name. Instead of replicating and manually editing the formula for 200 times, is there a way that i could make my formula dynamic by referencing to the cell values as sheet name?
Please note that i have other sheets with key data to be shown in the same workbook but not subject to the above criteria.
I am very new to VBA and only start working on it for a few days. Thanks for all your help!