im trying to add a button that will unprotect the sheet if it is protected, then delete the currect row and allow undo and then protect the sheet again
im using the sendkeys method to allow the undo, this works fine if the sheet does not need to be reprotected, it seems like the sendkeys is being done after the protect as it just fills the cell with text, if i delete the 5th line it works as needed but then leaves the sheet unprotected, any idea why this is not working?
Sub rowdelete()
If ActiveSheet.ProtectContents Then
ActiveSheet.Unprotect Password = "pass"
Application.SendKeys ("%EDR~")
ActiveSheet.Protect Password = "pass"
Else
Application.SendKeys ("%EDR~")
End If
End Sub
im using the sendkeys method to allow the undo, this works fine if the sheet does not need to be reprotected, it seems like the sendkeys is being done after the protect as it just fills the cell with text, if i delete the 5th line it works as needed but then leaves the sheet unprotected, any idea why this is not working?
Sub rowdelete()
If ActiveSheet.ProtectContents Then
ActiveSheet.Unprotect Password = "pass"
Application.SendKeys ("%EDR~")
ActiveSheet.Protect Password = "pass"
Else
Application.SendKeys ("%EDR~")
End If
End Sub