Working "Locking" Code in draft, not in project??

CBurgess

Board Regular
Joined
Oct 29, 2013
Messages
65
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If ActiveSheet.Cells(10, 4).Text <> "bacon" Then 'A drop down menu is listed on this cell, when "bacon" is selected I want C20 to be accessible
ActiveSheet.Unprotect
ActiveSheet.Range("C20").Locked = True
Else
ActiveSheet.Unprotect
ActiveSheet.Range("C20").Locked = False   'C20 will be a further drop down list so they can choose their further options dependant on the first selection
End If
ActiveSheet.Protect
End Sub

Hello,

I've got this code working for me in a blank excel file.

Yet when I use it in my actual project file, it's keeping cell "C20" unlocked regardless of the criteria in "D10".

Have you got any tips of what I can do, what to look out for?

I cannot see any spelling errors or any code that would counter act this?

Any help would be much appreciated,

Thank you!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,214,942
Messages
6,122,367
Members
449,080
Latest member
Armadillos

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top