Forum Discussion

Mick_Kitcher's avatar
Mick_Kitcher
Copper Contributor
Aug 18, 2023

Protect/Unprotect Sheet with a checkbox

Can anyone help please, CHAT GPT can't!!

I'm trying to record a macro to Protect/Unprotect a single sheet using a Checkbox in Excel 365 for Mac but am unable to mage it.

All suggestions warmly welcomed... ๐Ÿ™‚ 

Thanks in anticipation....

  • Mick_Kitcher 

    Does the attached workbook work on a Mac? The macro assigned to the check box is:

    Sub CheckBox1_Click()
        With Sheet1
            If .Shapes("Check Box 1").ControlFormat.Value = 1 Then
                .Protect ' Password:=:"Secret"
            Else
                .Unprotect ' Password:="Secret"
            End If
        End With
    End Sub

    Since it is a macro-enabled workbook, make sure that you allow macros when you open it.

    • Mick_Kitcher's avatar
      Mick_Kitcher
      Copper Contributor
      Hi Hans (again) before i try it i should have mentioned that i don't want to use a password, do i just ignore it or omit from the code? My sheet is named DATA by the way. ๐Ÿ™‚

      Thanks
      • HansVogelaar's avatar
        HansVogelaar
        MVP

        Mick_Kitcher 

        The password has been commented out in the code.

        You'll have to replace Sheet1 with Worksheets("Data") in the code, and "Check Box 1" with the name of your check box.

Resources