fijistrom
11-01-2018, 01:59 PM
I have been looking all through the interwebs looking for help with a nested IF statement. Here is the basic logic of what I am trying to accomplish.
Columns E and F are in a range of E#:F#.
If column e# = yes and column f# = yes then highlight cell gold
ElseIf column e# = yes and column f# = no then highlight cell green
ElseIf column e# = no and column f# = no then highlight row red
Else column e# = no and column f# = yes then highlight row orange
Here is the code I have. It is highlighting the cells with "yes" in gold and the cells with "no" in red.
Sub Macro1()
Dim cells As Range
For Each cells In Range("E2:F94")
If cells.Value = "Yes" And cells.Value ="Yes" Then
cells.Interior.Color = XlRgbColor.rgbGold
ElseIf cells.Value = "Yes" And cells.Value ="No" Then
cells.Interior.Color = XlRgbColor.rgbGreen
ElseIf cells.Value = "No" And cells.Value ="No" Then
cells.Interior.Color = XlRgbColor.rgbOrange
ElseIf cells.Value = "No" And cells.Value ="Yes" Then
cells.Interior.Color = XlRgbColor.rgbGold
End If
Next cells
End Sub
I am looking for some help with trying to get the cells to highlight based on the combination of Yes's and No's.
Thanks,
Nick
Columns E and F are in a range of E#:F#.
If column e# = yes and column f# = yes then highlight cell gold
ElseIf column e# = yes and column f# = no then highlight cell green
ElseIf column e# = no and column f# = no then highlight row red
Else column e# = no and column f# = yes then highlight row orange
Here is the code I have. It is highlighting the cells with "yes" in gold and the cells with "no" in red.
Sub Macro1()
Dim cells As Range
For Each cells In Range("E2:F94")
If cells.Value = "Yes" And cells.Value ="Yes" Then
cells.Interior.Color = XlRgbColor.rgbGold
ElseIf cells.Value = "Yes" And cells.Value ="No" Then
cells.Interior.Color = XlRgbColor.rgbGreen
ElseIf cells.Value = "No" And cells.Value ="No" Then
cells.Interior.Color = XlRgbColor.rgbOrange
ElseIf cells.Value = "No" And cells.Value ="Yes" Then
cells.Interior.Color = XlRgbColor.rgbGold
End If
Next cells
End Sub
I am looking for some help with trying to get the cells to highlight based on the combination of Yes's and No's.
Thanks,
Nick