how can I unhide/hide a sheet based on pull down selection?

K

Keith

I would like to know how you can make one of several hidden worksheets
visible based on a pull down selection on a visible worksheet.
 
G

Gord Dibben

With a DV dropdown list of sheets in D1 of an always visible sheet.

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Me.Range("D1")) Is Nothing Then Exit Sub
On Error GoTo endit
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
With Sheets(Target.Value)
If .Visible = False Then
.Visible = True
Else
.Visible = False
End If
End With
endit:
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste the code into that sheet module.

Adjust target range to suit.

Alt + q to return to the Excel window.


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top