Hide Worksheet with Combo Box

Ned Ludd

Board Regular
Joined
May 13, 2004
Messages
56
Hi Everybody!

I hope someone can help.

I have a workbook with 8 worksheets. I have hidden 3 (sheets 6,7 and 8) as I do not want my users to see them.

Of the remaining 5 worksheets, the user will only use 4 of them at any one time. I also have a combo box with yes and no answers.

If yes is selected, the user will use sheets 1,3,4,5. If no is selected, the user will use sheets 1,2,4,5.

What I want to do is have sheet 2 hidden if yes is selected and have sheet 3 hidden if no is selected.

Is there a way to do this without VB? (Or if it can only be done with VB, can you PLEASE be kind enough to give me the entire script as I have no idea how to use VB.)

Thank you very much.


Ned.
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Ned

Try
Code:
Private Sub ComboBox1_Change()
If ComboBox1.Value = "yes" Then
  Sheets("sheet2").Visible = False
  Sheets("sheet3").Visible = True
Else
 Sheets("sheet2").Visible = True
  Sheets("sheet3").Visible = False
End If
End Sub

It assumes that the combobox is called combobox1, it is from the control toolbox toolbar, and the numbers you have given refer to the sheet names, rather than the index position.

HTH

Tony
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,001
Messages
5,834,820
Members
430,324
Latest member
bosphoruskid

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
Top