I'm trying to make it work:
But for some reason it's not working. There is a 1004 error at:
Sheets("Formulario de Nova Contratacao").Protect Password:="3,1415", DrawingObjects:=True, Contents:=True, Scenario:=True
And the button are not working either. Even if i cancel the protection and unprotection functions.
Don't know what it's happening.
Function Bloquear()
' Bloqueia toda a planilha
' Para não bloqueá-la: digitar manut no campo B8
Application.ScreenUpdating = False
If Sheets("Formulario de Nova Contratacao").Range("B8") = "manut" Then Exit Function
Sheets("Formulario de Nova Contratacao").Protect Password:="3,1415", DrawingObjects:=True, Contents:=True, Scenario:=True
ThisWorkbook.Protect
End Function
Function Desbloquear()
' Desbloqueia toda a planilha
Worksheets("Formulario de Nova Contratacao").Unprotect Password:="3,1415"
ThisWorkbook.Unprotect
End Function
Private Sub OptionButton1_Click()
' Bandeira do Brasil: Mostra os Campos 9 e 10 (linhas 24 a 26)
' Campo 14 (Linhas 35 a 37)
' Campo 19.1 (Linhas 71 a 84)
' Esconde os Campos 4 e 5 (Linhas 10 a 12)
Call Desbloquear
If OptionButton1.Value = True Then
Rows("10:12").Hidden = True
Rows("24:26").Hidden = False
Rows("35:37").Hidden = False
Rows("71:84").Hidden = False
Call Bloquear
End If
End Sub
Private Sub OptionButton2_Click()
' Bandeira do Brasil: Mostra os Campos 9 e 10 (linhas 24 a 26)
' Campo 14 (Linhas 35 a 37)
' Campo 19.1 (Linhas 71 a 84)
' Esconde os Campos 4 e 5 (Linhas 10 a 12)
Call Desbloquear
If OptionButton1.Value = True Then
Rows("10:12").Hidden = False
Rows("24:26").Hidden = True
Rows("35:37").Hidden = True
Rows("71:84").Hidden = True
Call Bloquear
End If
End Sub
Bookmarks