Showing/hiding worksheets basd on cell content

Nardil

New Member
Joined
Aug 7, 2013
Messages
1
I have a workbook with a bunch of individual worksheets with specific information, as well as one general worksheet. I'd like to be able to put a name in one cell in the general sheet and have it automatically hide every worksheet but the one that shares a name with the content of that cell. Any help would be greatly appreciated.
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Put this code in the sheet code module of the general worksheet. I will use cell A2 in the code but you can change that to the actual cell that you will be using. The line where the cell reference must be changed are noted "Change"
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address <> "$A$2" Then Exit Sub 'Change
Set sh = Target.Parent
    If Range("A2").Value <> sh.Name Then 'Change
        Sheets(Range("A2").Value).Visible = True 'Change
    End If
    For Each wks In ThisWorkbook.Sheets
        If wks.Name <> sh.Name And wks.Name <> Range("A2").Value Then 'Change
            wks.Visible = False
        End If
    Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top