protect/unprotect all sheets

R

roos

I use the following code to protect/unprotect all sheets in a excel file:

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

It works well, but I would like that when I protect the sheets it will ask
twice for the password. Like excel ask normally when you protect sheet for
sheet.(tools, protection, protect sheet)
Who knows the code for this.
 
F

filo666

easy, in this line:
Else
wSheet.Protect Password:=TextBox1.Text
End If

you could add an userform (a new one) that asks the password again, and if
that password is different from textbox1.text then an error msgbox appears
HTH
 
R

roos

Ok, and the code to do this?
roos

filo666 said:
easy, in this line:
Else
wSheet.Protect Password:=TextBox1.Text
End If

you could add an userform (a new one) that asks the password again, and if
that password is different from textbox1.text then an error msgbox appears
HTH
 
F

filo666

still there????

filo666 said:
easy, in this line:
Else
wSheet.Protect Password:=TextBox1.Text
End If

you could add an userform (a new one) that asks the password again, and if
that password is different from textbox1.text then an error msgbox appears
HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top