View Single Post
 
Old 05-18-2017, 08:06 PM
YW3 YW3 is offline Windows 10 Office 2016
Novice
 
Join Date: Jan 2017
Posts: 10
YW3 is on a distinguished road
Default

"Run-time error '1004':

Unable to set the Locked property of the Range class

Continue | End | Debug | Help"

^ Happens regardless if I select "Yes" or "No".
Still able to edit A2 after selecting "No" and locking the sheet.

Both A1 and A2 are unlocked cells.

After I select Debug, the arrow points to:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Application.Intersect(Target, Range("A1")) Is Nothing Then
        If Range("A1").Value = "No" Then
            Range("A2").Value = 0
            Range("A2").Locked = True
        Else
            Range("A2").Value = ""
            Range("A2").Locked = False
        End If
    End If

End Sub

Last edited by YW3; 05-18-2017 at 10:40 PM.
Reply With Quote