I have a workbook having 7 sheets, named
MS, CWS, 1, 2, 3, 4, 5
On sheet MS there is a table in range C4:C8
I want to hide unhide sheets on the basis of table, except the sheet "CWS"
(Please see the attachment)
here is the code:
This code can be simplified, but I don't know how.Code:Private Sub Worksheet_Change(ByVal Target As Range) 'hide unhide sheet 1 If [C4] <> "" Then Sheet3.Visible = True Else Sheet3.Visible = False End If 'hide unhide sheet 2 If [C5] <> "" Then Sheet4.Visible = True Else Sheet4.Visible = False End If 'hide unhide sheet 3 If [C6] <> "" Then Sheet5.Visible = True Else Sheet5.Visible = False End If 'hide unhide sheet 4 If [C7] <> "" Then Sheet6.Visible = True Else Sheet6.Visible = False End If 'hide unhide sheet 5 If [C8] <> "" Then Sheet7.Visible = True Else Sheet7.Visible = False End If End Sub
Would you please help me to do so.




Reply With Quote
Bookmarks