以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何标注出多列内容相同的行  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=114307)

--  作者:lake163
--  发布时间:2018/2/2 16:55:00
--  如何标注出多列内容相同的行
假如表A,有C1、C2、C3、C4、C5等多列
如果C1、C2、C3完全相同,就认为是重复的行,则这些重复的行中只保留一行,其他多余的行在C5列写入“重复”
请教各位老师如何办啊?

--  作者:有点甜
--  发布时间:2018/2/2 17:39:00
--  

显示冗余重复值,参考

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列"
For Each dr As DataRow In DataTables("表A").Select("", "第一列,第二列")
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag OrElse pdr Is Nothing Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify in (" & idx.trim(",") & ")"

\'Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")"  \'显示唯一值

[此贴子已经被作者于2018/2/28 17:15:15编辑过]

--  作者:lake163
--  发布时间:2018/2/2 18:06:00
--  
万分感谢!