Results 1 to 4 of 4

My Code For Protecting Isn't working

Threaded View

  1. #1
    Registered User
    Join Date
    11-25-2020
    Location
    Brazil
    MS-Off Ver
    Office365
    Posts
    1

    My Code For Protecting Isn't working

    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
    Last edited by 6StringJazzer; 11-25-2020 at 08:00 PM. Reason: Please read the rules and use code tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help: Macro NOT Working After Protecting Sheet
    By g1987 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2020, 09:02 AM
  2. [SOLVED] Protecting Sheet stops searching from working
    By VisionSmart in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-05-2018, 12:46 AM
  3. [SOLVED] Protect Sheet not working after protecting workbook?
    By Nonie in forum Excel General
    Replies: 1
    Last Post: 06-24-2014, 10:29 PM
  4. [SOLVED] How to get control back from rogue code that keeps protecting my sheet wwhen I'm working
    By nje in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-21-2013, 09:14 AM
  5. [SOLVED] Protecting all but one worksheet macro not working
    By Shauna in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-04-2012, 01:24 PM
  6. Password protecting a workbook prevents Macros from working.
    By PeterMcCarthy in forum Excel General
    Replies: 3
    Last Post: 02-07-2012, 07:01 PM
  7. [SOLVED] up down arrows not working after protecting sheet
    By Computer Man 678 in forum Excel General
    Replies: 2
    Last Post: 12-04-2005, 07:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1