Block Delete/Insert row and column WITHOUT protecting sheet

dmax17

New Member
Joined
Jun 18, 2015
Messages
26
Hi,

I need to block Insert/Delete row commands WITHOUT protecting sheet. The reason is that I am adding rows in the sheet using VBA, but I do not want the user to have that ability beyond what the VBA affords them.

Anything I can do using VBA

Please help!

Thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
If you're adding rows in VBA, can you unprotect the sheet, add the rows, then reprotect it?

ActiveSheet.Protect
Rows("10").Insert
ActiveSheet.Unprotect
 
Upvote 0
Hi,

I need to block Insert/Delete row commands WITHOUT protecting sheet. The reason is that I am adding rows in the sheet using VBA, but I do not want the user to have that ability beyond what the VBA affords them.

Anything I can do using VBA

Please help!

Thanks

The worksheet.protect method includes an argument that allows VBA to work on the sheet as though it were not protected, but protects against changes through the user interface:
Rich (BB code):
'your code
Sheets("mySheet").Protect password:="your pswd here", userinterfaceonly:= True
'your code
 
Upvote 0
Thanks Joe ! This works great. But now I have another problem, my users lose the ability to sort. I have unlocked those particular cells, but I still can't sort.
Is there a way I could ensure that users are able to sort on particular fields in the worksheet?
 
Upvote 0
Thanks Joe ! This works great. But now I have another problem, my users lose the ability to sort. I have unlocked those particular cells, but I still can't sort.
Is there a way I could ensure that users are able to sort on particular fields in the worksheet?
You are welcome.

There's another argument for sorting:
Rich (BB code):
'your code 
Sheets("mySheet").Protect password:="your pswd here", userinterfaceonly:= True, allowsorting:= True
'your code
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,809
Members
449,048
Latest member
greyangel23

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