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
 

Some videos you may like

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

strategygamer

Board Regular
Joined
Aug 16, 2010
Messages
77
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
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

dmax17

New Member
Joined
Jun 18, 2015
Messages
26
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?
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,388
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,819
Messages
5,598,293
Members
414,223
Latest member
Accountant2B

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
Top