• 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.

VBA Code to Hide/Unhide Sheets Based On Dropdown List Selection

katymaelittle

New Member
I have a workbook with several worksheets. I want certain worksheets to unhide based on a selection in a dropdown list consisting of merged cells (rng f20:j20"). The dropdown list also has dependent drop lists associated to it (rng a27:d27), also merged cells. I have written a code that will unhide the sheets based on the selection in the first drop down list, however, when I select an item in the next dependent drop down, the sheets disappear again. Is there a way to write the code so that it is not affected by an entry into the dependent drop down list? My knowledge of writing VBA Code is VERY SLIM. Below is the code I'm using on the active sheet "Application Info". This is the first time I've posted a question in a forum so please let me know if I need to give more info, etc. Thanks in advance!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
For i = 2 To ThisWorkbook.Sheets.Count
 ThisWorkbook.Sheets(i).Visible = False
Next
  Dim rng As Range
  Dim ws As Worksheet
  Set rng = Target.Parent.Range("f20:j20")
  If Intersect(Target, rng) Is Nothing Then Exit Sub
  For Each ws In ActiveWorkbook.Worksheets
  If Target.Value = "" Then ws.Visible = True
  Next ws
  Sheets(Target.Value).Visible = True
  Sheets("Application Cost").Visible = True
  Sheets("National Questions").Visible = True
  Sheets("Certification").Visible = True
 
 
 
End Sub
Mod Edit: Code Tags added
 
Last edited by a moderator:
Back
Top