Prevent user from inserting / deleting rows

Corleone

Well-known Member
Joined
Feb 2, 2003
Messages
841
Office Version
  1. 365
i have used the code below which works fine in that greys out the insert / delete options from the menu,,however, the user would still be able to insert/delete by right clicking and diong it that way, can any one offer a soloution for this (i would like to do this without using the protection option)
Thanks




Private Sub Worksheet_Activate()
Dim objCmdBrPp As CommandBarPopup

Set objCmdBrPp = Application.CommandBars("Worksheet Menu Bar").Controls("Insert")
objCmdBrPp.Controls("Rows").Enabled = False
End Sub

'=================================================

Private Sub Worksheet_Deactivate()
Dim objCmdBrPp As CommandBarPopup

Set objCmdBrPp = Application.CommandBars("Worksheet Menu Bar").Controls("Insert")

objCmdBrPp.Controls("Rows").Enabled = True
End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi Corleone,

I believe you can disable menu options on the Cell shortcut menu like this:

CommandBars("Cell").Controls("Insert...").Enabled = False

and of course the same for the Delete option.

Keep Excelling.

Damon
 
Upvote 0
Hi Corleone,

I believe you can disable menu options on the Cell shortcut menu like this:

CommandBars("Cell").Controls("Insert...").Enabled = False

and of course the same for the Delete option.

Keep Excelling.

Damon

thanks for your help

I Finally opted for creating a "disable macro" to be run on files to be sent out
Sub EnableMenu()
CommandBars("Worksheet Menu Bar").Controls("Insert").Enabled = True
CommandBars("Worksheet Menu Bar").Controls("Format").Enabled = True
End Sub

but with an enable macro included so i can get the menu options back again.


it would be easier to protect the sheets ut it means having to go through all the existing code which toggles on and off the protected worksheets in numerous areas
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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