seanduffy
03-21-2010, 08:11 PM
I need to prevent the modification of four cells in my worksheet w/o using the built in Excel protection settings (the users of the document need full, unrestricted access to everything else in the worksheet). Ideally this would prevent modifications to even the font and color of the cells, but at a minimum, it'd need to prevent their deletion.
I've tried the code below but the problem with it is if that I select a range that includes the cells, I'm able to still delete them or clear their contents. I can also simply delete the whole row that the cells I want to "protect" are in.
Any ideas!? Thanks!
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$R$1" Or Target.Address = "$T$2" Or Target.Address = "$T$3" Or Target.Address = "$T$4" Then
Application.EnableEvents = False
MsgBox "This cell is protected, sorry!"
Application.Undo
Application.EnableEvents = True
End If
End Sub
I've tried the code below but the problem with it is if that I select a range that includes the cells, I'm able to still delete them or clear their contents. I can also simply delete the whole row that the cells I want to "protect" are in.
Any ideas!? Thanks!
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Address = "$R$1" Or Target.Address = "$T$2" Or Target.Address = "$T$3" Or Target.Address = "$T$4" Then
Application.EnableEvents = False
MsgBox "This cell is protected, sorry!"
Application.Undo
Application.EnableEvents = True
End If
End Sub