VBA to unhide sheets based on cell contents

djl0525

Well-known Member
Joined
Dec 11, 2004
Messages
1,240
This code below works great to unhide sheets in my workbook.

Sub ShowExerciseSheets()
'This macro is run from the Welcome sheet
'It will unhide the Intro sheet, 6 exercise sheets and the blank sheet
'Comment out the sheets do not want to unhide


Application.ScreenUpdating = False
MsgBox ThisWorkbook.Sheets("MsgBoxes").Range("B2").Value, , "Training."
Sheet05.Visible = True 'unhide Introduction
Sheet10.Visible = True 'unhide 1st exercise sheet
Sheet20.Visible = True 'unhide 2nd exercise sheet
Sheet30.Visible = True 'unhide 3rd exercise sheet
Sheet40.Visible = True 'unhide 4th exercise sheet
Sheet50.Visible = True 'unhide 5th exercise sheet
Sheet60.Visible = True 'unhide 6th exercise sheet
Sheet99.Visible = True 'unhide blank sheet


'Activate the Introduction! Sheet
Worksheets("Introduction").Activate
Range("A1").Select


Application.ScreenUpdating = True


End Sub

Instead of opening the VB Editor to comment out sheets I don't want to display, I'd like the code to look at one of my sheets to see which sheets to unhide.

Sheetnames - The sheets are listed in columns A on the "Trainer's Sheet 1" sheet. The sheet names listed are the actual tab names (not Sheet05, Sheet10, etc.)

Which sheets to display - Column B contains Yes or No. Yes for unhide. No for do not unhide.

I'd like help modifying the code to unhide sheets where it finds Yes in column B next to the respective sheetname.

Any assistance will be greatly appreciated!

DJ
 
Log into the forum. In the upper left hand corner you should see a black button that says "+Post New Thread".
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,215,444
Messages
6,124,893
Members
449,194
Latest member
JayEggleton

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