Consulting

Results 1 to 5 of 5

Thread: 2016 Excel VBA Code for Locking a Cell after Data Entry

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    5
    Location

    2016 Excel VBA Code for Locking a Cell after Data Entry

    I have made a macro for my spreadsheet that is supposed to conditional lock cells aft date is entered. I've tried running the macro but I get a debug notice at this lie cl.Locked = "True"

    This is the full macro: I am hoping someone can help me resolve the issue

    Private Sub Worksheet_Change(ByVal Target As Range)
    Dim cl As Range
    ActiveSheet.Protect Password:="123"
    For Each cl In Target
    If cl.Value <> "" Then
    check = MsgBox("Is this entry correct? This cell cannot be edited after entering a value.", vbYesNo, "Cell Lock Notification")
    If check = vbYes Then
    cl.Locked = "True"
    Else
    cl.Value = ""
    End If
    End If
    Next cl
    Activeshet.Protect Password:="123"
    Last edited by Aussiebear; 05-13-2022 at 12:44 PM. Reason: Added code tags for supplied code

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •