• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Button to lock cells

I have an approval button on my form which I want to use to lock all the cells so they can't be changed. See attached
 

Attachments

  • Approval.xlsm
    28.5 KB · Views: 3
Hi lesley,

Can you check this:

Code:
Sub Button1_Click()
    ActiveSheet.Unprotect Password:="G1ng3r"
    Range("B5:M15").SpecialCells(xlCellTypeConstants).Locked = True
    ActiveSheet.Protect Password:="G1ng3r"
End Sub

Regards,
 
ok, link your drop down with a cell say P19

now include this line in your code:
Code:
Range("P19").SpecialCells(xlCellTypeConstants).Locked = True

OR
Code:
Range("B5:O15", "P19").SpecialCells(xlCellTypeConstants).Locked = True

Regards,
 
I'm back again I have the links for the dropdowns on another tab. I have tried
Sheet8.Range("H3").SpecialCells(xlCellTypeConstants).Locked = True

but it doesn't work, Any idea's
 
I'm back again I have the links for the dropdowns on another tab. I have tried
Sheet8.Range("H3").SpecialCells(xlCellTypeConstants).Locked = True

but it doesn't work, Any idea's
Welcome back :)

There might be efficient way, but I came up with:

Code:
Sub Button1_Click()
    ActiveSheet.Unprotect Password:="G1ng3r"
    Range("B5:O15", "P19").SpecialCells(xlCellTypeConstants).Locked = True
    Application.Goto ActiveWorkbook.Sheets("Sheet3").Range("H3")
    ActiveSheet.Unprotect Password:="G1ng3r"
    Range("H3").SpecialCells(xlCellTypeConstants).Locked = True
    ActiveSheet.Protect Password:="G1ng3r"
    Application.Goto ActiveWorkbook.Sheets("Sheet1").Range("A1")
    ActiveSheet.Protect Password:="G1ng3r"
End Sub

Please check
I will be back tomorrow.
 
Back
Top