Help with Macros button to apply password to unlock worksheet, run macros, then lock again

lbillie

New Member
Joined
Jun 21, 2013
Messages
28
I am trying to apply a macros to an active x button. When checking the button, it should enter password to unprotect worksheet, it wll only show rows of all true statements retrieved from Column AL, when unchecked it should allow the user to view all rows regardless if AL column is true or false, then apply the password again to lock the work sheet. This is my formula for the checkbox. Any help is greatly appreciated.

Code:
Private Sub CheckBox1_Click()
  If CheckBox1 Then
  ActiveSheet.Unprotect Password:="Insight"
  ActiveCell.Locked = True
  
    Range("AL5:AL154").AutoFilter Field:=1, Criteria1:="TRUE"
  Else
    ActiveSheet.AutoFilterMode = False
    
    ActiveSheet.Protect Password:="Insight"
    ActiveCell.Locked = False
    
  End If
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
I left out some information, sorry about that. I click on the button to check it, it works, to uncheck it; it give me a debug flag. ActiveCell.Locked = False is highlighted.
 
Upvote 0

Forum statistics

Threads
1,215,527
Messages
6,125,337
Members
449,218
Latest member
Excel Master

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