Hi, This macro does almost exactly what I need to do but it only works on sheet 1 and a single range (a8 to b20) .
Can you help me to adjust it so it will work for multiple sheets ( sheet 2,3, etc) and multiple ranges on a single sheet.
The ranges will be different for each sheet.
Thank you very much.
Sub Protect()
Dim i As Integer
Sheet1.Unprotect "Password"
If Range("A8:B20").Locked = False Then
Range("A8:B20").Locked = True
For i = 8 To 20
Cells(i, 1).Interior.ColorIndex = 35
Cells(i, 2).Interior.ColorIndex = 35
Next i
Else
Range("A8:B20").Locked = False
For i = 8 To 20
Cells(i, 1).Interior.ColorIndex = 2
Cells(i, 2).Interior.ColorIndex = 2
Next i
End If
Sheet1.Protect "Password"
Sheet1.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True
Sheet1.EnableSelection = xlUnlockedCells
End Sub
Bookmarks