error 1004 cannot set locked property of range class

akanowhere

New Member
Joined
Jan 4, 2021
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Theres no merge cell in this sheet. That sheet is locked.


Private Sub Worksheet_Change(ByVal Target As Range)


If Range("A11") <> "" Then
Range("B1:L11").Locked = False
ElseIf Range("A11") = "" Then
Range("B11:L11").Locked = True
End If


End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Do you have sheet protection on?
If so, you will need to first unprotect the sheet before you can lock/unlock the cells.
You can add that right to the code, if you like.
 
Upvote 0
Do you have sheet protection on?
If so, you will need to first unprotect the sheet before you can lock/unlock the cells.
You can add that right to the code, if you like.
Yes the sheet is protected.....
 
Upvote 0
Yes the sheet is protected.....
Protection wouldn't be worth much if you could simply bypass it by using VBA code! ;)
Here is a link that shows you how to code it to unprotect it first (with and without password, depending on if you are using one).

You will just want to be sure to turn it back on at the end of your code.
 
Upvote 0
Solution
Protection wouldn't be worth much if you could simply bypass it by using VBA code! ;)
Here is a link that shows you how to code it to unprotect it first (with and without password, depending on if you are using one).

You will just want to be sure to turn it back on at the end of your code.
I will test that and return....tks for your attention
 
Upvote 0
The article solve my problem. Tks a lot for spend your time to help to solve this problems.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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