MrExcel Publishing
Your One Stop for Excel Tips & Solutions

protecting cells

Posted by hassan on October 11, 2001 4:09 AM

Hi can anyone help.

Is there anyway I can have a situation where a cell
is only protected once a user has entered data into it.

ie if a cell is empty the user is free to enter data,
once the data is entered the user cannot then change the cell unless he/she has the protection password.

any help would be appreciated.

Posted by Juan Pablo on October 12, 2001 12:34 PM

Use this

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target <> "" Then
Target.Locked = True
End If
End Sub

Juan Pablo