I have an excel sheet with multiple buttons. The sheet needs to be unclocked in order for the macros to run. Although I have found short VBA codes that protect/ unprotect the sheet when run independently, when these are integrated into a button's code, unprotecting the sheet does not work. The code for a particular button is:
Sub OptionButton56_Click()
ActiveSheet.Unprotect Password:="Password"
If Range("D33").Value = 2 Then
Sheets("Input").Rows("34:35").Hidden = msoTrue
ElseIf Range("D33").Value = 1 Then
Sheets("Input").Rows("34:35").Hidden = msoFalse
End If
ActiveSheet.Protect Password:="Password"
End Sub