VB code Hide Rows AND hide Sheets

Joshua_JC

New Member
Joined
Jul 16, 2014
Messages
5
Hi there,

So posted below is the code i am working with.

Basically the user will use the checkbox this is assigned to, to select items.
If the item is checked, then the row on the results tab is made visible and the sheet for that item is also made visible.
If the item is NOT checked, then the row on the results tab is made hidden as is the sheet for that item.

I can get the Hide rows to work but for some reason when I add in the code to Hide the sheets, the button attached to the code will ONLY hide the rows.


Code:
Private Sub CheckBox8_Click()
If CheckBox1 = True Then
Sheets("Results").Rows("11").EntireRow.Hidden = False
Sheet3.Visible = False '.VWorksheets("Sheet3").Visible = False
End If
If CheckBox1 = False Then
Sheets("Results").Rows("11:14").EntireRow.Hidden = True
Sheet3.Visible = True 'Worksheets("Sheet3").Visible = True
End If
End Sub

I have also tried to use the code this way. (Also with no results)

Code:
Private Sub Checkbox2_Click()
If CheckBox1 = True Then
Sheets("Results").Rows("15").EntireRow.Hidden = False
Sheets("Sheet3").Visible = True
End If
If CheckBox1 = False Then
Sheets("Results").Rows("15").EntireRow.Hidden = True
Sheets("Sheet3").Visible = False
End If
End Sub

Thoughts on what Im doing wrong here?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
This worked for me:
Code:
Private Sub CheckBox1_Click()
    If CheckBox1 = True Then
        Sheets("Results").Rows("15").EntireRow.Hidden = False
        Sheets("Sheet3").Visible = True
    Else
        Sheets("Results").Rows("15").EntireRow.Hidden = True
        Sheets("Sheet3").Visible = False
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,264
Messages
6,171,085
Members
452,378
Latest member
Hoodzy01

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