经过几天的学习揣摩lsy兄的源代码,我做了一个任意列数重复值判断的通用代码给有需要的同学,假设我们用:上级部门 单位名称 姓名 3列来做判断
Dim str0 As New List (Of String)
Dim str1 As New List (Of String)
Dim id0,id1,flt,celltext As String
For Each r As Row In CurrentTable.Rows
celltext=r("上级部门")&r("单位名称")&r("姓名")
If str0.Contains(celltext) =False Then
id0 + = r("_Identify") & ","
Else
str1.Add(celltext)
End If
str0.Add(celltext)
Next
For Each r As Row In CurrentTable.Rows
celltext=r("上级部门")&r("单位名称")&r("姓名")
If str1.Contains(celltext) Then
id1 + = r("_Identify") & ","
End If
Next
If id1 > "" Then
id1 = id1.Trim(",")
End If
If id1 > "" Then
flt = "_Identify In (" & id1 & ")"
End If
CurrentTable.Filter = flt
CurrentTable.Sort="上级部门,单位名称,姓名"
大家只要修改红色的部分,就能用来判断任意多列的重复值