Hide/Unhide Sheet Macro

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
 
D

Dave Peterson

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
 
T

Thomp

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
 
D

Dave Peterson

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.
 
T

Thomp

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
 
D

Dave Peterson

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.
 
Joined
Sep 22, 2010
Messages
1
Reaction score
0
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top