Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Aug 2001
    Surrey, United Kingdom
    Thanked 0 Times in 0 Posts

    Unlock protected sheet and then re-lock (2003 SP2)

    Good morning

    I have a form with locked cells, it has 2 buttons on a form, when the macro from either is run I want to temporarily unlock the sheet, update the cells and then re-lock it.

    When I wanted to delete certain cells using a button Rudi gave me this advice in this post <post#=684449>post 684449</post#> , however on this occassion I am not using a button and would like to run it as part of the macros already assigned to the 2 buttons but I am not sure if I have (a) adapted it correctly and ( where to place it in the existing macros

    Private Sub CommandButton1_Click() <font color=448800>(Do I have to make this the name of the button on my form Private Sub StockControl.xls!AutoShape1_Click()</font color=448800>

    Application.Calculation = xlCalculationManual
    Application.ScreenUpdating = False

    Worksheets("summary").Unprotect Password:="pass"

    Application.ScreenUpdating = True
    Application.Calculation = xlCalculationAutomatic

    Worksheets("summary").Protect Password:="pass"

    End Sub




    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Pittsburgh, Pennsylvania, USA
    Thanked 342 Times in 335 Posts

    Re: Unlock protected sheet and then re-lock (2003 SP2)

    Yes teh Click event needs to match the name of the object on the userform.

    If the button is on a sheet and from the Control Toolbox, it also must include the name of the button

    If the button is from the FORMS toolbar, then there is no "event" monitoring and the macro is just a regular sub and you must assign the macro to run when the button is pressed (right click on it and assign macro...)


Posting Permissions

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