protecting multiple ranges in different sheets

siddharth_kale

New Member
Joined
Dec 29, 2010
Messages
24
Hi,

Is there a way in which I could protect A1:A5 and C1:C5 in different sheets?

It is quite tedious to select multiple ranges like this and allow specific users to edit these ranges and that too in different sheets.

Please let me know if there is a better way to do it.

Regards,
Siddharth
 

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.
This is fairly ugly but will give you some code to work with.

code to unprotect all sheets

Sub Protect_Example1()
' Loop through all sheets in the workbook.
For i = 1 To Sheets.Count
Sheets(i).Unprotect

Next i
End Sub

code to protect all sheets

Sub Protect_Example1()
' Loop through all sheets in the workbook.
For i = 1 To Sheets.Count
Sheets(i).Protect

Next i
End Sub

Code to go through 2 sheets and do something with a range in each sheet, if you need more copy part of the code and alter sheet names.

Sub Macro2()
'
' Recorded Macro to Protect sheet but unlock ranges
'
Sheets("Sheet2").Select
Range("A1:A5,C1:C5").Select
Range("C1").Activate
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
Sheets("Sheet3").Select '
Range("A1:A5,C1:C5").Select
Range("C1").Activate
Selection.Locked = False
Selection.FormulaHidden = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,844
Messages
6,127,252
Members
449,372
Latest member
charlottedv

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