VBA to hide all sheets in a list

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have a list of sheet names in sheet "Welcome" Range "C7:C200"

I just want a macro that will hide all of them

Thanks

Tony
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
If this is to work with your question earlier, the code will need amending, if you double click to select a sheet that is hidden it will fail.
 
Upvote 0
I've already dealt with that but thank you for pointing it out, and yes it will be working along side that VBA.
Thanks

Tony
 
Upvote 0
Maybe
Code:
Sub HideSheets()
   Dim Cl As Range
   For Each Cl In Range("C7:C200")
      On Error Resume Next
      Sheets(Cl.Value).Visible = xlHidden
      On Error GoTo 0
   Next Cl
End Sub
 
Last edited:
Upvote 0
@Dryver14
I've modified the code, forgot to change it back to xlHidden after using it to unhide the sheets I'd just hidden.
Thanks for spotting that
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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