I want to clear and reset the conditional formatting rules for my workbook. There are groups of values that I want conditionally formatted to show as Green, Yellow, Orange, Red, and Pink. The values for each color group are stored in an array.
Below is my code so far, but only showing the for loops for green and yellow. I get the error on this line Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual,Formula1:=item
Sub ResetFormat()
Dim ws As Worksheet
Dim item As Variant
Dim arrGreen As Variant
arrGreen = Array(Worksheets("Drop down").Range("N11:N14"))
Dim arrYellow As Variant
arrYellow = Array(Worksheets("Drop down").Range("O11:O13"))
Dim arrOrange As Variant
arrOrange = Array(Worksheets("Drop down").Range("P11:P14"))
Dim arrRed As Variant
arrRed = Array(Worksheets("Drop down").Range("Q11:Q14"))
Dim arrPink As Variant
arrPink = Array(Worksheets("Drop down").Range("R11:R12"))
For Each ws In Sheets
Cells.Select
Selection.Cells.FormatConditions.Delete
For Each item In arrGreen
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=item
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 5287936
.TintAndShade = 0
End With
Next item
For Each item In arrYellow
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _
Formula1:=item
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
End With
Next item
Next ws
End Sub