VBA to change cell from "Locked" to "Unlocked" based on another cell input

CaptBrownShoes

New Member
Joined
May 16, 2024
Messages
5
Office Version
  1. 2021
Platform
  1. Windows
Would like to unlock a cell to allow input ONLY when another cell has the met criteria.

Current State:
Protected Sheet with no password
Cell L11 is "Locked"


Desired Outcome:
I want to unlock cell L11 when someone enters "Yes" in Cell O10
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
This macro assumes that cell O10 is unlocked. Copy and paste the macro into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter "Yes' In O10 and press the ENTER key.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("O10")) Is Nothing Then Exit Sub
    If Target = "Yes" Then
        With ActiveSheet
            .Unprotect
            .Range("L11").Locked = False
            .Protect
        End With
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

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