You are on page 1of 2

Sub Proteger()

Dim Psw As String


Do While Psw = ""
Psw = Trim(InputBox("joycocalidad"))
Loop
For Each ws In Worksheets
ws.Protect Psw
Next
End Sub
Sub DesProteger()
Dim Psw As String
Do While Psw = ""
Psw = Trim(InputBox("joycocalidad"))
Loop
For Each ws In Worksheets
ws.Unprotect Psw
Next
End Sub

Crear un boton de comando

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

Crear un modulo

Sub MostrarFormulario()
UserForm1.Show
End Sub

You might also like