delete row with undo and protect

fatdog

New Member
Joined
Mar 2, 2011
Messages
4
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
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Forum statistics

Threads
1,224,503
Messages
6,179,136
Members
452,890
Latest member
Nikhil Ramesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top