VBA Hide/Unhide Multiple Sheets based on Column of Data

woodbutcher

New Member
Joined
Oct 17, 2018
Messages
2
I have 100 sheets in a workbook that have dynamic names.

The sheet numbers are static and start in G14 and continue to G113
in column H starting at H14:H113 is a "NO" "YES" designator to say if the sheet should be visible or not.

I would like the sheets to hide or unhide on the selection of the next sheet.

I'm new to VBA so any help would be greatly appreciated.

Thanks
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Hi there, I'm not exactly sure what you mean by hide or unhide on the selection of the next sheet, but you can try this (this assumes that the sheet with yes and no on it is sheet 1):

Code:
Dim cell As Range
Dim rng as Range

Set rng = Sheets(1).Range("H14:H113")

For Each cell in rng
    If InStr(cell.Value, "NO") Then
        Sheets(cell.Offset(0, -1).Value).Visible = False
            Else
        Sheets(cell.Offset(0, -1).Value).Visible = True
    End If
Next cell
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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