This macro will put color of cells in column A into column B.
It then sort those 2 columns and delete all similar color but the first cell.
It then delete column 2.
If you have data past columns B, change the sort range A1:B500 to suit your data.
Public Sub test()
Dim C_ell As Range
For Each C_ell In Range("A1:A500")
C_ell.Offset(0, 1) = C_ell.Interior.ColorIndex
Next
Range("B2").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("B2"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A1:B500")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
For Each C_ell In Range("B1:B500")
'C_ell.Select
While C_ell.Offset(1, 0) = C_ell
C_ell.Offset(1, 0).EntireRow.Delete
Wend
Next
Cells(2, 2).EntireColumn.Delete
End Sub
Bookmarks