Klash Ville
Board Regular
- Joined
- Sep 19, 2017
- Messages
- 83
Currently I have this code that with the support of conditional formatting, is able to detect all duplicates, but makes them have the same exact color. This is a problem because I have a gigantic table and looking at everything with the same color.
Code:
Range("Table2[[#Headers],[Plastic (kg)]]").Select
Selection.ListObject.ListColumns.Add
Range("Table2[[#Headers],[Column1]]").Select
ActiveCell.Offset(1, 0).Activate
ActiveCell.FormulaR1C1 = _
"=RC[-19]&RC[-17]&RC[-15]&RC[-14]&RC[-13]&RC[-12]&RC[-11]&RC[-10]&RC[-9]&RC[-8]&RC[-7]&RC[-6]&RC[-5]&RC[-4]&RC[-3]&RC[-2]&RC[-1]"
Range("Table2[Column1]").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
Selection.FormatConditions(1).StopIfTrue = False
With ActiveWorkbook.Worksheets("Feuil1").ListObjects("Table2").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.ListObjects("Table2").Range.AutoFilter Field:=20, Criteria1:= _
RGB(255, 199, 206), Operator:=xlFilterCellColor
Range("Table2").Select
ActiveCell.Offset(1, 0).Activate
Do While ActiveCell.EntireRow.Hidden = True
ActiveCell.Offset(1, 0).Activate
Loop
If Not IsEmpty(ActiveCell) Then
Range(Selection, Selection.End(xlDown)).Select
With Selection.Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
End With
End If
Range("Table2[[#Headers],[Column1]]").Select
ActiveCell.Offset(0, -1).Activate
ActiveCell.Offset(1, 0).Activate
Do While ActiveCell.EntireRow.Hidden = True
ActiveCell.Offset(1, 0).Activate
Loop
If ActiveCell.Interior.ColorIndex = 6 Then
Columns("T:T").Select
Selection.Delete Shift:=xlToLeft
Range("A1").Select
If MsgBox("Duplicated rows have been found, do you wish to ignore them?", vbCritical + vbYesNo) = vbNo _
Then
MsgBox "The macro will now come to an halt in order for you to re-check your data.", vbInformation
Exit Sub
End If
End If
Columns("T:T").Select
Selection.Delete Shift:=xlToLeft