Hide/Unhide Sheet Macro

  • Thread starter Thread starter Thomp
  • Start date Start date
T

Thomp

Is there a way to use a checkbox that if the checkbox is checked then
it unhides a sheet but if it not checked then it hides the sheet

thanks
 
If you used a checkbox from the Control toolbox toolbar, you can use a macro
like:

Option Explicit
Private Sub CheckBox1_Click()
If Me.CheckBox1.Value = True Then
Worksheets("sheet1").Visible = xlSheetVisible
Else
Worksheets("sheet1").Visible = xlSheetHidden
End If
End Sub
 
If you used a checkbox from the Control toolbox toolbar, you can use a macro
like:

Option Explicit
Private Sub CheckBox1_Click()
    If Me.CheckBox1.Value = True Then
        Worksheets("sheet1").Visible = xlSheetVisible
    Else
        Worksheets("sheet1").Visible = xlSheetHidden
    End If
End Sub

That works great..thanks..One small question how do I now move that
check box location on the sheet if I want to move it up or down a bit
 
Click on the design mode icon on that same control toolbox toolbar.

Then just drag the checkbox by its border to the new location.

And then leave design mode.
 
Click on the design mode icon on that same control toolbox toolbar.

Then just drag the checkbox by its border to the new location.

And then leave design mode.







--

Dave Peterson- Hide quoted text -

- Show quoted text -

Thanks very much Dave..you are awesome..this works great. Could I ask
one more question if I want to hide/unhide more than one sheet at a
time how would I do that.
thanks,
Bill
 
Just keep adding more and more sheets to the code:

Worksheets("sheet1").Visible = xlSheetVisible
Worksheets("sheet2").Visible = xlSheetVisible
Worksheets("sheet3").Visible = xlSheetVisible
Worksheets("sheet4").Visible = xlSheetVisible

(and same for the hiding portion)

Remember that at least one sheet has to be visible at all times.
 
I have never written computer code before so bear with me.

I have a drop down box in cell B18, with four options (a, b, c, d). How do I write a macro to say that when 'a' is chosen from the drop down box, tab 1 will appear. It will continue, when 'b' is chosen, tab 2 will appear. I want the other tabs to be hidden when the associated choice in the menu is not chosen.

Many thanks.
 
Back
Top