in the following VBA-Code i'm trying to give the Cells in Range("H1:IV1") different colors based on the content of the Cell
Sub AddColor()
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("H1:IV1")
For Each cel In SrchRng
If InStr(1, cel.Value, "|unsichtbar|") > 0 Then
cel.Interior.Color = vbRed
End If
If InStr(1, cel.Value, "|lesen|") > 0 Then
cel.Interior.Color = vbYellow
End If
If InStr(1, cel.Value, "|schreiben|") > 0 Then
cel.Interior.Color = vbGreen
End If
Next cel
End Sub
my questions are:
1- How can i set the Variable "SrchRng" to search in first Row not just in Range("H1:IV1")?
2- The changing color Code works good on the cell but i need to apply the color on the Column where the if-statement true.