I have set from conditional formatting in vba to make cell color yellow if top 5 highest cost down (CD) amount. Now, I am stuck at Step (2) below. Where I'd like to input YES into column Propose? if the cell color is yellow. The rest will be input as NO. Actually this vba code can run if the cell is manually colored and not by conditional formatting by vba. Do you have any other way to do? Thank you in advance for your time.
Sub Sort ()
Dim R2 as Range
'(1)Change cell to yellow if CD amount top 5 highest
Set R2 = range ("O18","O206")
R2.FormatConditions.Delete
R2.FormatConditions.AddTop10
With R2.FormatConditions(1)
.TopBottom.xlTop10Top
.Rank=5
End With
'(2) Input "YES" to Top 5 highest CD, the rest input "NO". Skip for blank rows
Range("J18","J206").ClearContents
For Each R2 in Range ("O18","O206")
If R2.Cells.Interior.Color=RGB(255,255,0) Then
Cells(R2.Row,"J").Value = "YES"
Else
Cells (R2.Row,"J").Value="NO"
End If
Next R2
End Sub
Reference: Input "YES/NO" to a cell depending other column color