Hi.
I have a code that allows the end user to delete selected rows from a protected table. The problem is, as it is now my macro can delete pretty much anything that gets selected and I'm worried that something else outside the table will eventually get deleted by accident, even though I've got an alert message you have to agree to first and everything.
Could someone help me complete my code so that only rows types of objects can get deleted, possibly only if within a specified named range?
Thanks in advance.
I have a code that allows the end user to delete selected rows from a protected table. The problem is, as it is now my macro can delete pretty much anything that gets selected and I'm worried that something else outside the table will eventually get deleted by accident, even though I've got an alert message you have to agree to first and everything.
Could someone help me complete my code so that only rows types of objects can get deleted, possibly only if within a specified named range?
Thanks in advance.
Code:
Sub Delete_Click()
'
' Delete_Click Macro
'
'
Application.ScreenUpdating = False
ActiveSheet.Unprotect
Dim answer As Integer
[INDENT]answer = MsgBox("Are you sure you want the selected object to be deleted?", vbYesNo + vbQuestion, "Delete rows")[/INDENT]
[INDENT]If answer = vbYes Then[/INDENT]
[INDENT=2]Selection.Delete Shift:=xlUp[/INDENT]
[INDENT=2]Else if[/INDENT]
[INDENT=3]'do nothing[/INDENT]
[INDENT]End If[/INDENT]
ActiveSheet.Protect
Application.ScreenUpdating = True
End Sub