Macro to hide sheets based on cell value on each sheet

pontuskrusing

New Member
Joined
Sep 2, 2014
Messages
4
I would like to get a macro that:
- Hides several sheets
- Hide sheets based on value in cell E:226 each sheet, IF cell value is 0 then hide sheet
- IF cell equals value other than 0, unhide or stay unhided
Someone that can help me with that?

Thank you in advance.
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try something like this:

Code:
Sub HideSht()
    
    Dim x As Long
    
    For x = 1 To Sheets.Count
        If Sheets(x).Range("E226") = 0 Then
            Sheets(x).Visible = False
        End If
    Next x
    
End Sub
 
Upvote 0
Code:
    For x = 2 To ThisWorkbook.Sheets.Count        
          If Sheets(x).Cells(226, 5) = 0 Then Sheets(x).Visible = False Else Sheets(x).Visible = True
    Next x

This will hide every sheet after the first one. You can't hide them all, so I left the first one alone.
 
Upvote 0
Thank you!
So, do I enter the macros separately or combined?

Code:
    For x = 2 To ThisWorkbook.Sheets.Count        
          If Sheets(x).Cells(226, 5) = 0 Then Sheets(x).Visible = False Else Sheets(x).Visible = True
    Next x

This will hide every sheet after the first one. You can't hide them all, so I left the first one alone.
 
Upvote 0

Forum statistics

Threads
1,214,643
Messages
6,120,707
Members
448,981
Latest member
recon11bucks

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