To unlock all yellow cells (colour index 36) and lock all non-yellow cells, I'm attempting to develop a vba macro. The code below runs, but I'm having trouble putting it in a for loop so that it runs through all of the sheets in my workbook rather than just "Sheet1."
Sub test()
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
For Each cell In Sheet1.UsedRange
If cell.Interior.ColorIndex = 36 Then
cell.Locked = False
End If
Next
ws.Protect userinterfaceonly:=True
End Sub