Forum Discussion
CatherineMadden
Jun 25, 2024Brass Contributor
Lock/Unlock All Tabs
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
- JKPieterseSilver ContributorThere 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.