Cell Lock/Unlock based on other cell's value

afenrick86

New Member
Joined
Sep 4, 2014
Messages
6
I am trying to figure something out and I realized that it will take a little VBA to complete my request. I have a cell that is unlocked, Sheet2:A1, by default because the cell in Sheet1:A1 is blank. If someone puts text in Sheet1:A1 then I want Sheet2:A1 to lock where it can't be changed. Any help or suggestions? Any way around VBA? If not, that is fine, just trying not to complicate things too much.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
In sheet 1 would this work?

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub
    If Target = Range("A1") Then Call lockingsheet
End Sub

Sub lockingsheet
if sheets("Sheet1").range("A1").value <> 0 then
Sheets("Sheet2").protect password:="ABC123")
else 
Sheets("Sheet2").unprotect password:="ABC123")
End if
end sub
 
Upvote 0
Lee,

Thanks for the quick reply. I think the top half of that will work, but I will already have Sheet 2 locked because I have other cells that I don't want modified. I am just needing the single cell to lock and unlock instead of the whole sheet. Does that make sense?
 
Upvote 0

Forum statistics

Threads
1,222,229
Messages
6,164,738
Members
451,911
Latest member
HMF009

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