Excel 2010突出显示连续3列中的2列是重复的

时间:2014-07-15 12:07:47

标签: excel-2010

我需要突出显示重复的患者,因此,如果3列中的2列是重复的,我希望它突出显示。目前有正常的重复规则,有很多重复显示,因为名称通常是常见的,因此,列A患者名字,B姓氏C nhs数字,如果nhs数字或第一或姓氏是重复我想要它为了突出。我已经说过3分中有2分允许拼写错误/ anmomalies,谢谢:)

1 个答案:

答案 0 :(得分:0)

试试这个小宏:

Sub NameChecker()

Dim N As Long, i As Long, j As Long, _
    v1 As String, v2 As String, v3 As String, _
    w1 As String, w2 As String, w3 As String, _
    Kount As Long

N = Cells(Rows.Count, "A").End(xlUp).Row

For i = 1 To N - 1
    v1 = Cells(i, 1)
    v2 = Cells(i, 2)
    v3 = CStr(Cells(i, 3))
    For j = i + 1 To N
        w1 = Cells(j, 1)
        w2 = Cells(j, 2)
        w3 = CStr(Cells(j, 3))
        Kount = -(v1 = w1) - (v2 = w2) - (v3 = w3)
        If Kount > 1 Then
            Range("A" & j & ":C" & j).Interior.ColorIndex = 27
        End If
    Next j
Next i
End Sub

以下是一个例子:

demo

第一个条目有几个近似重复。