You can use below VBA codes to Protect and Unprotect all Worksheets In Active Workbook.
Password is used as "RED" (use password without quotes)
Code to Protect All Worksheets In Active Workbook.
Sub ProtectAllSheets()
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Start looping through all worksheets
For Each ws In ActiveWorkbook.Worksheets
'Step 3: Protect and loop to next worksheet
ws.Protect Password:="RED"
Next ws
End Sub
Code to Un-Protect All Worksheets In Active Workbook.
Sub UnprotectAllSheets()
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Start looping through all worksheets
For Each ws In ActiveWorkbook.Worksheets
'Step 3: Protect and loop to next worksheet
ws.Unprotect Password:="RED"
Next ws
End Sub
Password is used as "RED" (use password without quotes)
Code to Protect All Worksheets In Active Workbook.
Sub ProtectAllSheets()
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Start looping through all worksheets
For Each ws In ActiveWorkbook.Worksheets
'Step 3: Protect and loop to next worksheet
ws.Protect Password:="RED"
Next ws
End Sub
Code to Un-Protect All Worksheets In Active Workbook.
Sub UnprotectAllSheets()
'Step 1: Declare your variables
Dim ws As Worksheet
'Step 2: Start looping through all worksheets
For Each ws In ActiveWorkbook.Worksheets
'Step 3: Protect and loop to next worksheet
ws.Unprotect Password:="RED"
Next ws
End Sub
No comments:
Post a Comment