• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hide worksheets based on drop down value selected

Waylander

New Member
I have a workbook with 11 worksheets.

On my control sheet, I have a drop down where users can select the reason for using the workbook and depending on their selection I would like some workbooks to be visible and others to be hidden.

The choices in the drop down box are; Option 1 - All - show all sheets
Option 2 - show sheets 1,2,4,5 and 6
Option 3 - show sheets 1,3,4 and 7
Option 4 - show sheets 1,4,8,9,10 and 11

Any help you can give would be much appreciated.

Thank you
 
Add the following code to the worksheet Module of the sheet which has the drop down
Adjust the ranges to suit
Make sure the worksheet is not in the Sheets(1) to Sheets(11) range

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub 'Adjust range to suit where Drop Down is

Select Case [A1] 'Adjust range to suit where Drop Down is
  Case 1
  For i = 1 To 11
  Sheets(i).Visible = True
  Next i
 
  Case 2
  Sheets(Array("Sheet3", "Sheet7", "Sheet8", "Sheet9", "Sheet10", "Sheet11")).Visible = False
  Sheets("Sheet1").Visible = True
  Sheets("Sheet2").Visible = True
  Sheets("Sheet4").Visible = True
  Sheets("Sheet5").Visible = True
  Sheets("Sheet6").Visible = True
 
  Case 3
  Sheets(Array("Sheet2", "Sheet5", "Sheet6", "Sheet8", "Sheet9", "Sheet10", "Sheet11")).Visible = False
  Sheets("Sheet1").Visible = True
  Sheets("Sheet3").Visible = True
  Sheets("Sheet4").Visible = True
  Sheets("Sheet7").Visible = True

  Case 4
  Sheets(Array("Sheet2", "Sheet3", "Sheet5", "Sheet6", "Sheet7")).Visible = False
  Sheets("Sheet1").Visible = True
  Sheets("Sheet4").Visible = True
  Sheets("Sheet8").Visible = True
  Sheets("Sheet9").Visible = True
  Sheets("Sheet10").Visible = True
  Sheets("Sheet11").Visible = True

  Case Else
  For i = 1 To 11
  Sheets(i).Visible = True
  Next i

End Select

End Sub
 
Back
Top