redbaron85914
redbaron85914

Reputation: 11

Unlocking cells of a specific colour and locking all other cells

I have a workbook containing 22 separate worksheets.

I've colour-coded the input cells green. Is there a formula/macro that automatically unlocks only the green cells and locks everything else.

enter image description here

Upvotes: 1

Views: 729

Answers (1)

user6028892
user6028892

Reputation:

Try this - replacing the ColorIndex and sheet name where necessary

Sub test()

    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")
    For Each cell In Sheet1.UsedRange
        If cell.Interior.ColorIndex = 35 Then
            cell.Locked = False
        End If
    Next

    ws.Protect userinterfaceonly:=True

End Sub

Let me know if you need help looping through each worksheet.

Upvotes: 1

Related Questions