Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
作一按钮检查重复行
在表A中如果a,b,c,d,e.f.g列有数据相同超过2行则视为重复,并且全部筛选出来。
求教代码?
直接筛选是没有办法的,用Select语句吧。
这样可以吗:
Dim id As String
For ci As Integer = 0 To CurrentTable.cols.count -1
CurrentTable.Filter = ""
Dim lm As String = CurrentTable.cols(ci).name
CurrentTable.Select(0,ci)
Tables("表A").focus
Syscmd.Filter.ShowSameValues()
For i As Integer = 0 To CurrentTable.count -1
Dim rr As Row = Tables("表A").Rows(i)
If rr(lm) <> ""
' If id.contains(Tables("表A").Rows(i)("_identify")) = False
id = id & "[_identify] = " & Tables("表A").Rows(i)("_identify") & " or "
' End If
End If
Next
Next
output.show(id.substring(0,id.Length-4))
Tables("表A").Filter = id.substring(0,id.Length-4)
顺便问一下老师们 :‘上面粉红色的这个if语句有什么问题,怎么会提示错误呢 ??
Tables("表A").Rows(i)("_identify")得出的值是整数
id.contains应该是判断是否包含字符
你先做转换整数型为字符型试试看
这样所有列中有重复值时都可以筛选出来了:
With DataTables("表A")
.StopRedraw
Dim id0,id As String
For ci As Integer = 0 To CurrentTable.cols.count -1
CurrentTable.Filter = ""
Dim lm As String = CurrentTable.cols(ci).name
CurrentTable.Select(0,ci)
Tables("表A").focus
Syscmd.Filter.ShowSameValues()
For i As Integer = 0 To CurrentTable.count -1
Dim rr As Row = Tables("表A").Rows(i)
If rr(lm) <> ""
Dim ide As String = rr("_identify")
If id Is Nothing
id = id & "[_identify] = " & rr("_identify") & " or "
Else
If id <> "" And id.contains(ide) = False
id = id & "[_identify] = " & rr("_identify") & " or "
End If
End If
End If
Next
'Exit For
Next
Tables("表A").Filter = id.substring(0,id.Length-4)
.ResumeRedraw
End With