搜索模式 [英] Searching for patterns
问题描述
我有一个excel文件,我需要在列中查找重复的数据...
我正在将单个字符串与该列的每个数据进行比较,并找到匹配项,它对于较小的列数据也可以正常工作.
但是问题在于,由于一列(例如2000行)中有较大的数据,程序执行时间比预期的要长.
任何人都可以建议我任何更简单的省时方法来快速找到Excel文件中的重复项...
希望你能理解.
I have an excel file and I need to find the repetations of data in a column ...
I am Comparing a single string with each data of that column and finding for a match and it''s working fine for small column datas..
But the problem is that as there are larger data in a column (say 2000 rows) the program is taking longer time for execution than expected.
Can anyone suggest me any simpler time saving method to quickly find for repetations in a excel file...
I hope U understand.
For Rep As Integer = 1 To 100
Obj = CType(range.Cells(Rep, cCnt), Range)
If Obj.value <> Nothing Then
arr1 = Obj.value
Else
arr1 = "NL"
End If
For Rep1 As Integer = Rep + 1 To 100
Obj = CType(range.Cells(Rep1, cCnt), Range)
If Obj.value <> Nothing Then
arr2 = Obj.value
Else
arr2 = "NL"
End If
If arr1.Equals(arr2) Then
Comp += 1
End If
Next
Next
从comp值中,我确定是否重复数据
From the comp value I am determining whether data is repeted or not
推荐答案
尝试首先对数据进行排序.一旦数据更改,这可以通过中断内部循环来提高性能.
Try sorting your data first. This can boost performance by breaking your inner loop as soon as data changes.
这篇关于搜索模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!