Lock/Unlock All Tabs

Brass Contributor

I have the macro below to lock/unlock all of the tabs at 1 time. How do I add a line to use ALT+L to lock and ALT+U to unlock?

 

Sub ProtectAll()
Dim wsh As Worksheet
For Each wsh In Worksheets
wsh.Protect Password:="1020"
Next wsh
End Sub

Sub UnprotectAll()
Dim wsh As Worksheet
For Each wsh In Worksheets
wsh.Unprotect Password:="1020"
Next wsh
End Sub

1 Reply
There are two ways to do that.
1. Application.OnKey (check out Help) turn on in your Workbook_Open and off in workbook_BeforeClose event
2. From the Macros dialog (alt+F8 from Excel), select a macro and click Options.