شنبه یازدهم مرداد ۱۳۹۹ - 14:13 - حسين حسين پور -
Let’s say you just want to highlight cells with duplicate values from the selection, this code can help you in this.
To use this code you just need to select a range of cells and run this code. It checks each cell with the selection and highlights it with red color if a cell has a duplicate value.
Sub DuplicateValuesFromSelection() Dim myRange As Range Dim i As Integer Dim j As Integer Dim myCell As Range Set myRange = Selection For Each myCell In myRange If WorksheetFunction.CountIf(myRange, myCell.Value) > 1 Then myCell.Interior.ColorIndex = 3 End If Next Next End Sub