How to protect / unprotect all sheets in one go using VBA in Excel

preview_player
Показать описание
In this tutorial you will learn how protect and unprotect all worksheets in one go using VBA macro programming in Microsoft Excel

VBA Code:

'This code will protect all the sheets at one go
Sub ProtectAllSheets()
Dim ws As Worksheet
Dim password As String
password = "Pass123" 'replace Test123 with the password you want
For Each ws In Worksheets
ws.Protect password:=password
Next ws
End Sub

'This code will unprotect all the sheets at one go
Sub UnprotectAllSheets()
Dim ws As Worksheet
Dim password As String
password = "Pass123" 'replace Test123 with the password you want
For Each ws In Worksheets
ws.Unprotect password:=password
Next ws
End Sub
Рекомендации по теме
Комментарии
Автор

How to join all scrip income one? Thnx

mafpin
Автор

How do I protect the first 9 worksheets out of 15 sheets in workbook

noelbaptist
Автор

Nice system but file closed, again unprotected option below

mizanurrahman
Автор

Awesome instructional video (I just watched someone else trying to explain this process without using VBA). THANK YOU MUCH!!!

robmonroe
Автор

Thank u, but if I need to allow to input data and only hide the formulas

eslamfahmy
Автор

If I need to get allow for some areas to input data and hide a formula only ?

eslamfahmy
Автор

its not asking for password to unprotect?

itguy
Автор

12 locked worksheets unlocked at once! Thank you!

lilianav
Автор

Very good, cut through all the rubbish and solved the problem. Thank you

thedarkshadow