Hi All,
Here is VBA method to lock the cell after entering data in the cell.
Note: adjust the RangeToLock to suit. This code goes in the sheet module of the sheet in question.Code:Dim blnUnlockedAllCells As Boolean Private Sub Worksheet_Change(ByVal Target As Range) Const RangeToLock As String = "A2:D1000" '<< adjust to suit If Target.Cells.Count > 1 Then Exit Sub If Not blnUnlockedAllCells Then Me.Cells.Locked = False On Error Resume Next Me.Range(CStr(RangeToLock)).SpecialCells(2).Locked = True On Error GoTo 0 blnUnlockedAllCells = True Me.Protect Password:="pwd", userinterfaceonly:=True End If If Not Application.Intersect(Target, Me.Range(CStr(RangeToLock))) Is Nothing Then If Len(Target) Then Target.Locked = True End If End Sub
I hope this helps !




Reply With Quote

Bookmarks