Checkbox for hiding/unhiding data

pencekj

New Member
Joined
Jul 16, 2021
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Hello,

I've added a checkbox with a macro tied to it but can't seem to get it to work right. Currently I've gotten this part working below (hiding and unhiding a tab) but I also want it to hide/unhide rows 6:11 on a separate sheet labeled "Required Info". I feel like I just can't seem to think straight and can't get this working. What would I add into this code to where the button also hides those rows on a separate sheet? The checkbox is not on the same sheet as any of the ones being referenced in the code.

Thanks


Sub DEPButton()

Dim HideSheet As Boolean
HideSheet = Range("G4")

If HideSheet Then
Sheets("Device Enrollment Program (DEP)").Visible = True
Else
Sheets("Device Enrollment Program (DEP)").Visible = False
End If

End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
How about ...

VBA Code:
Sub DEPButton()

    Dim HideSheet As Boolean
    HideSheet = Range("G4")

    If HideSheet Then
        Sheets("Device Enrollment Program (DEP)").Visible = True
        Worksheets("Required Info").Rows("6:11").Hidden = False
    Else
        Sheets("Device Enrollment Program (DEP)").Visible = False
        Worksheets("Required Info").Rows("6:11").Hidden = True
    End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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