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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Watch MrExcel Video

Forum statistics

Threads
1,129,685
Messages
5,637,809
Members
416,983
Latest member
LessThanAverageUser

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
Top