Got any Excel/VBA Questions? Excel Help
Excel has protection that we can add to an Excel Worksheet via Tools>Protection>Protect Sheet. A password can also be supplied so that another user cannot unprotect it without the password.
A common question that I'm often asked is, "how can I password protect and unprotect all Worksheets in my Workbook in one go. I have many sheets and I have to protect and unprotect each Worksheet individually." Unfortunately there is no standard feature in Excel that will allow us to protect and unprotect all Worksheets in one go, however, we can use some fairly simple VBA code to do this for us. Follow the steps below:
Private Sub CommandButton1_Click() Dim WSheet As Worksheet For Each WSheet In Worksheets If WSheet.ProtectContents = True Then WSheet.Unprotect Password:=TextBox1.Text Else WSheet.Protect Password:=TextBox1.Text End If Next WSheet Unload Me End Sub
Sub ShowPass() UserForm1.Show End Sub
This newly added feature will unprotect all Worksheets that are protected and protect all Worksheets that are unprotected.
A WORD OF WARNING: As you are not asked to confirm your password you should be very sure of what you type.
See also:
See also: Index to Excel VBA Code; Index to Excel Freebies; Lesson 1 - Excel Fundamentals; Index to how to… providing a range of solutions
Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions. Online slots all their lifetime was popular online casino game https://casinomasta.com/casino-games/ . Several years ago slot machines gone completely new level – all gamblers can play slot machines with their own storyline, excellent music and nice graphic.