+ Reply to Thread
Results 1 to 2 of 2

lock cell after data entry

  1. #1
    Jim St. Martin
    Guest

    lock cell after data entry

    I would to automatically lock/protect cells after entering data. Is this
    possible and how do I do it?

    Thank you in advance for your help.



  2. #2
    Dave Peterson
    Guest

    Re: lock cell after data entry

    Cell "lockedness" goes hand in hand with worksheet protection.

    You can lock the cell with a worksheet event like this:

    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)

    Dim myCell As Range

    If Me.ProtectContents = False Then
    Exit Sub
    End If

    Me.Unprotect Password:="pwd"
    For Each myCell In Target.Cells
    With myCell
    If IsEmpty(.Value) Then
    'do nothing
    Else
    .Locked = True
    End If
    End With
    Next myCell
    Me.Protect Password:="pwd"

    End Sub

    Rightclick on the worksheet tab that should have this behavior and select view
    code. Paste this into code window.

    It unprotects the worksheet, locks the cell, and reprotects the worksheet.
    Change the password to match yours.

    But I'm not sure that I'd do this. I make a lot of typing errors. If you lock
    the cell, then how would I be able to fix my typo?

    And on top of that worksheet protection is pretty easily broken.

    "Jim St. Martin" wrote:
    >
    > I would to automatically lock/protect cells after entering data. Is this
    > possible and how do I do it?
    >
    > Thank you in advance for your help.


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1