Write a VBA code that removes duplicates from only cells that are highlighted?
Question:
I would like to only remove duplicates of cells that are highlighted (in yellow). I was wondering if it is possible to do that.
Answers:
I would like to only remove duplicates of cells that are highlighted (in yellow). I was wondering if it is possible to do that.
Answers:
Say we have a column of values, some of which are hi-lighted in yellow. Say the column contains duplicates. For example:

This macro will examine the yellow cells and remove duplicates:


This macro will examine the yellow cells and remove duplicates:
Here is the result:Sub TheKingInYellow() Dim N As Long, i As Long, wf As WorksheetFunction N = Cells(Rows.Count, 1).End(xlUp).Row Set wf = Application.WorksheetFunction For i = N To 2 Step -1 With Cells(i, 1) v = .Value c = .Interior.ColorIndex If wf.CountIf(Range(Cells(i - 1, 1), Cells(1, 1)), v) > 0 And c = 6 Then .Delete End If End With Next i End Sub

Commentaires
Enregistrer un commentaire