Hello All,
I would like a Macro/s that is/are able to protect and unprotect specific worksheets. This is so that other Macros can then access the data on these sheets.
Currently I have a Macro, taken from another thread, that Protects and Unprotects all of the worksheets. This works fine, however it takes quite a while and I had hoped having a Macro to Protect/Unprotect only the worksheets that are needed would be beneficial. Below is the code I have to Protect/Unprotect all worksheets;
Any help you can give me would be greatly appreciated.
Kind regards.
Connor
I would like a Macro/s that is/are able to protect and unprotect specific worksheets. This is so that other Macros can then access the data on these sheets.
Currently I have a Macro, taken from another thread, that Protects and Unprotects all of the worksheets. This works fine, however it takes quite a while and I had hoped having a Macro to Protect/Unprotect only the worksheets that are needed would be beneficial. Below is the code I have to Protect/Unprotect all worksheets;
Code:
Sub UnprotectAll()
Application.ScreenUpdating = False
Dim sh As Worksheet
Dim yourPassword As String
yourPassword = "111"
For Each sh In ActiveWorkbook.Worksheets
sh.Unprotect Password:=yourPassword
Next sh
Application.ScreenUpdating = True
End Sub
Code:
Sub ProtectAll()
Application.ScreenUpdating = False
Dim sh As Worksheet
Dim yourPassword As String
yourPassword = "111"
For Each sh In ActiveWorkbook.Worksheets
sh.Protect Password:=yourPassword
Next sh
Application.ScreenUpdating = True
End Sub
Any help you can give me would be greatly appreciated.
Kind regards.
Connor