I have this macro (it's macro from addin PLEX) it's working but I need to make a loop from
so he stops when an empty space is reached
Sub Duplicates_Coloring()
Dim rngData As Range, i As Integer
Dim Dupes()
Colors = Array(33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 53, 19, 20, 22, 27, 28)
If SelectionCheck(Selection) = False Then
MsgBox "Select range with the data where you want to highlight duplicates. This operation can not be performed on a protected sheet, with cells in the summary table, with a diagram or a picture!", vbCritical + vbOKOnly, "Incorrect Selection"
Exit Sub
End If
If Selection.CountLarge = ActiveSheet.Cells.CountLarge Then
MsgBox "Do not select the entire sheet. Select only range with the data where you want to highlight duplicates.", vbExclamation + vbOKOnly, "Incorrect Selection"
Exit Sub
End If
Set rngData = Intersect(Selection, ActiveSheet.UsedRange)
If rngData Is Nothing Then
MsgBox "Select range with the data where you want to highlight duplicates!", vbExclamation + vbOKOnly, "Incorrect Selection"
Exit Sub
End If
ReDim Dupes(1 To rngData.Cells.Count, 1 To 2)
Application.ScreenUpdating = False
rngData.Interior.ColorIndex = -4142
i = 1
For Each cell In rngData
If WorksheetFunction.CountIf(rngData, cell.Value) > 1 Then
For k = LBound(Dupes) To UBound(Dupes)
If Dupes(k, 1) = cell Then cell.Interior.ColorIndex = Dupes(k, 2)
Next k
If cell.Interior.ColorIndex = -4142 And i < UBound(Colors) Then
cell.Interior.ColorIndex = Colors(i)
Dupes(i, 1) = cell.Value
Dupes(i, 2) = Colors(i)
i = i + 1
End If
End If
Next cell
Application.ScreenUpdating = True
If i > 20 Then MsgBox i & " duplicates were found. First 20 were highlighted by color.", vbExclamation + vbOKOnly, "Too many duplicates!"
End Sub