I have 2 columns in my excel sheet which I want to have protected in a way that you can't delete the cell nor its content. I don't want to use the built in sheet protection, instead I want to use VBA (because of no password needed). I found some code which should prevent cells from being deleted, but it doesn't work. Also I have no idea how VBA works and therefore I would be happy if someone can either provide a solution or guide me on how to do it myself.
The code I found is this:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A6:B1048576")) Is Nothing Then Exit Sub
On Error GoTo ExitPoint
Application.EnableEvents = False
If Not IsDate(Target(1)) Then
Application.Undo
End If
ExitPoint:
Application.EnableEvents = True
End Sub