I found a very helpful example online to control what tabs are displayed in a excel spreadsheet/workbook based on the value of a drop down menu but I need to take it a step further and all of my experimenting isn't paying off.....I am not savvy at all in VB coding.
Here is an example of what I have so far and it works perfectly.....the drop down in on the first tab cell D10....
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address <> "$D$10" Then Exit Sub
Select Case Target
Case "DROPDOWN VALUE ONE"
Sheets("TABANAME").Visible = xlSheetVisible
Sheets("TABBNAME").Visible = xlSheetVeryHidden
Sheets("TABCNAME").Visible = xlSheetVeryHidden
Sheets("TABDNAME").Visible = xlSheetVeryHidden
Case "DROPDOWN VALUE TWO "
Sheets("TABANAME").Visible = xlSheetVisible
Sheets("TABBNAME").Visible = xlSheetVisible
Sheets("TABCNAME").Visible = xlSheetVeryHidden
Sheets("TABDNAME").Visible = xlSheetVeryHidden
Case "DROPDOWN VALUE THREE"
Sheets("TABANAME").Visible = xlSheetVeryHidden
Sheets("TABBNAME").Visible = xlSheetVeryHidden
Sheets("TABCNAME").Visible = xlSheetVisible
Sheets("TABDNAME").Visible = xlSheetVeryHidden
Case "DROPDOWN VALUE FOUR"
Sheets("TABANAME").Visible = xlSheetVeryHidden
Sheets("TABBNAME").Visible = xlSheetVeryHidden
Sheets("TABCNAME").Visible = xlSheetVeryHidden
Sheets("TABDNAME").Visible = xlSheetVisible
Case Else:
End Select
End Sub
What I need to be able to do is have another drop down on "TABDNAME" that also controls what tabs are in view like this drop down on the first tab does. I tried to go to TABDNAME and bring up the VB screen and add code for that tab only but I see the code that is used for the first tabs drop down so that leads me to believe that the VB code is not entered "per tab" and something in the VB code needs to say something along the lines of use this for the first drop down and use this for the other drop down all withing the same bit of code.....
Here is how I want to use workbook if it helps to understand the end result I am looking for....
Everyone starts on TABANAME and selects from the drop down the view they need and enters information based on their responsibility. no one uses TABDNAME. I than go to TABDNAME which is a collimation of all the data entered from the other tabs to make sure people entered everything completely.
What I need to be able to do is from TABDNAME select from another drop down what tabs I want shown before sending it to someone else. The tabs that I would select to view are populated off of TABDNAME, say TABENAME, TABFNAME, etc which I did not show here for simplicity.....
I have tried to play with the VB code that I have and cannot get it to work.
any help would be great and I hope this was not too confusing...again new at all of this
Copyright © 2025 Q2A.ES - All rights reserved.
Answers & Comments
Verified answer
In the VBE, each worksheet has its own 'tab'. Your first event handler, in your question, resides in the code module for that worksheet.
To enter the code module for the worksheet 'TabDName', right click on the sheet tab at the bottom, and select 'View Code'.
Enter your event handlers for that sheet in the editing area displayed.