hi, i have created a userform to unprotect/protect all worksheets in a workbook, so in the userform i have a textbox and a command button, in the userform code i have this, the problem is where do i put the password in this code?
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
</PRE>
</PRE>
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
</PRE>
</PRE>
Last edited: