Insertig/deleting rows in VBA

Sebyq

New Member
Joined
Aug 1, 2016
Messages
11
Hi guys,

I was wondering if anyone could help me with this? I would like a macro to block users of a shared spreadsheet from inserting/deleting rows without protecting it. So in essence they should be able to amend anything on it apart from inserting or deleting rows? Could anyone help me out on this? I looked online for the last 2 days nd I can`t find anything?

Many thanks!
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I think you will have to protect the sheet to do that !
You will still be able to carry out almost ALL other functions, except delete AND Inserting rows
you will also need to Unlock ALL cells first
Select all cells>>Rclick>>Format>Protection>>uncheck Locked
Then paste this is the Sheet Module that it applies to !

Code:
Private Sub WorkSheet_Activate()
    ActiveSheet.Protect AllowInsertingRows:=False, AllowDeletingRows:=False
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,357
Messages
6,124,482
Members
449,165
Latest member
ChipDude83

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