Error when trying to lock 2 cells containing a drop down list

benprelf

New Member
Joined
Aug 28, 2014
Messages
34
I want to be able to lock 2 cells containing a drop down list (both cells contain the same list), but only if a certain value is selected in another drop down list that the former is linked to.

Otherwise I would like the cells to be unlocked. The code I am using is:

Code:
Sub BlockFibre()
If Target.Address = "D10:E10" Then      'These cells contain the drop down list I do not want to lock
ThisWorkbook.Sheets("CreateCableEXM").Unprotect
Cells.Locked = True


If ThisWorkbook.Sheets("CreateCableEXM").range("D10:E10") = "MM" Then
    Set ThisWorkbook.Sheets("CreateCableEXM").range("J14:K14").Locked = False      'These cells contain the drop down list I want to lock
Else
    ThisWorkbook.Sheets("CreateCableEXM").range("J14:K14").Locked = True


End If
Set ThisWorkbook.Sheets("CreateCableEXM").range("D10:E10").Locked = False
ThisWorkbook.Sheets("CreateCableEXM").Protect
End If
End Sub

When attempting to run the code I receive "Run-time error '424' Object required" on this line:

Code:
If Target.Address = "D10:E10" Then

Any help would be much appreciated.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,191,719
Messages
5,988,290
Members
440,148
Latest member
sandy123

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