Code: Select all
Sub AOColorEm()
Dim cel As Range
Dim varColor As Variant
Application.ScreenUpdating = False
' Reset color
Range("D5:K2000").Interior.ColorIndex = xlColorIndexNone
' Set color
For Each cel In Range("D5:K5000").SpecialCells(xlCellTypeConstants)
varColor = Application.VLookup(cel.Value, Range("N5:O100"), 2, False)
If VarType(varColor) = vbDouble Then
cel.Interior.ColorIndex = varColor
End If
Next cel
Application.ScreenUpdating = True
End Sub
Code: Select all
Private Sub CommandButton22_Click()
Call AOColorEm
End Sub