I am looking to colour fill a range of cells (C2:C7) in Excel based on the the text selected in a cell (there will be a drop-down menu, two of the values being "SD" and "CS"). Here is my code so far:
Sub ChangeColor() Dim rCell As Range
With Sheet1
For Each rCell In .Range("C2:C7")
If rCell.Value <= SD Then
rCell.Interior.Color = vbRed
ElseIf rCell.Value <= CS Then
rCell.Interior.Color = vbGreen
Else: rCell.Interior.Color = vbYellow
End If
End With
End Sub
I'm told there is a compile error: End With without With
I'm just getting started in VBA so can somebody please tell me what I've done wrong?
Conditional formatting
is also a way to do this :D as long as you manage it properly it will not make the sheet bulky.. – bonCodigo