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

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

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,883
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,883
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,471
Messages
5,831,844
Members
430,089
Latest member
beesz

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