Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("col_M")) Is Nothing Then
Application.EnableEvents = False
If Target.Rows.Count = Range("A1", Cells(Rows.Count, "A")).Rows.Count Then
Application.EnableEvents = True
Exit Sub
End If
If Target.Columns.Count = Range("A1", Cells(1, Columns.Count)).Columns.Count Then
Application.EnableEvents = True
Exit Sub
End If
Application.Undo
MsgBox "You can only insert or delete whole columns or rows, not change cells."
Application.EnableEvents = True
End If
End Sub
|