Hello!
How would I password protect the same ranges across all the sheets in a workbook? For example I would like to lock down ranges H6:19 and E22:E29, across all existing sheets. I'm brand new to VBA and have been trying to look online most of today on how to do this. So far I came across this but it gives me a run-time error '1004' unable to set the locked property of the range class. Debugging points to "Selection.Locked = False"
Sub Protect_Range_Cells()
Dim range_1 As Range
Set range_1 = Range("h9:E8")
Cells.Select
Selection.Locked = False
range_1.Select
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False
End Sub
Does the tab need to be locked first? Is it possible to lock merged cells in the ranges?
Thanks!
How would I password protect the same ranges across all the sheets in a workbook? For example I would like to lock down ranges H6:19 and E22:E29, across all existing sheets. I'm brand new to VBA and have been trying to look online most of today on how to do this. So far I came across this but it gives me a run-time error '1004' unable to set the locked property of the range class. Debugging points to "Selection.Locked = False"
Sub Protect_Range_Cells()
Dim range_1 As Range
Set range_1 = Range("h9:E8")
Cells.Select
Selection.Locked = False
range_1.Select
Selection.Locked = True
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:=False
End Sub
Does the tab need to be locked first? Is it possible to lock merged cells in the ranges?
Thanks!