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.
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.
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks