In vba Find the value in column by Color RGB(255,199, 206) and Write the single Value as "Duplicate" in next column

Viewed 92

In vba Find the value in column by Color RGB(255,199, 206) and Write the single Value as "Duplicate" in next column. Please view the snap for more understanding.

enter image description here

I am trying below code to highlight the Cells and then I wanted to use new code to print "duplicate" infront of highlighted cells . Can you please guide me .

Sub Highlight_Duplicate_Value()

Columns("AD:AD").Select
Selection.FormatConditions.AddUniqueValues
Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
Selection.FormatConditions(1).DupeUnique = xlDuplicate
With Selection.FormatConditions(1).Font
.Color = -16383844
.TintAndShade = 0
End With
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 13551615
.TintAndShade = 0
End With
End Sub

Thank You

1 Answers

Something like this? Note this only checks interior color.

Sub colorcheck()
Dim Checkrange As Range
Dim cell As Range
lastrow = ActiveSheet.Cells(Rows.Count, "AD").End(xlUp).Row
Set Checkrange = ActiveSheet.Range("AD1:AD" & lastrow)
    For Each cell In Checkrange
    
If cell.DisplayFormat.Interior.Color = 13551615 Then
cell.Offset(0, 1).Value = "Duplicate"

End If
Related