我正在寻找这个帮助。我需要检查一个Excel文件大约。根据多种条件,类似记录的40000条记录。我还需要这一点,对于那些不完全精通IT的人来说,只要经常表现出来,就会非常万无一失。因此,基于宏观或基于公式的解决方案将是首选。
开始时似乎很容易。数据有一个标题行,每行一个记录。使用条件格式来突出显示一列或多列中包含重复数据的行很容易,但我有一个额外的复杂功能。
问题:我需要找到E列和F列(姓氏和DOB)中具有相同数据的记录,如果K列中的日期相似(即10天内),我需要将记录突出显示为重复彼此的)。只有满足所有3个条件时,记录才会突出显示为潜在副本。
这可能吗?我愿意接受建议。
答案 0 :(得分:0)
Function MATCHER(str1 As Range, rng1 As Range, str2 As String, rng2 As Range, num1 As Long, rng3 As Range, lim1 As Long)
Dim col(2) As Range, ws As Worksheet, rng As Range, str11 As String, FirstRow As Long, LastRow As Long
MATCHER = False
Set ws = rng1.Worksheet 'finds the worksheet of the first range (assumes all three ranges are on the same worksheet)
FirstRow = str1.Row + 1
LastRow = ws.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row 'find the last row in the worksheet
Set rng = ws.Range("1:" & LastRow) 'look down to the last row, inclusive
Set col(0) = Intersect(rng1.Columns, rng) 'apply the above criterion
Set col(1) = Intersect(rng2.Columns, rng) 'apply the above criterion
Set col(2) = Intersect(rng3.Columns, rng) 'apply the above criterion
For i = FirstRow To LastRow 'from first to last row
If col(0)(i, 1).Value2 = str1.Value2 Then 'if the first range variable's first column's value in row equals the first string variable
If col(1)(i, 1) = str2 Then 'if the second range variable's first column's value in row equals the second string variable
If col(2)(i, 1) >= num1 - lim1 And col(2)(i, 1) <= num1 + lim1 Then 'if the third range variable's first column's value in row equals the lookup value in confidence interval
MATCHER = True 'then it is true
Exit Function 'and there's no point in looking further
End If
End If
End If
Next
End Function
Sub ertdfgcvb()
x = MATCHER(Range("A1"), Range("A1"), "B", Range("B1"), 200, Range("C1"), 10)
MsgBox x
End Sub
对于实时环境中的运行时注意事项测试。第一个n-1记录的输出 TRUE ,其中n =相似的记录 它适用于单个记录集。