|
- Private Declare Function hash Lib "ntdll.dll" Alias "RtlComputeCrc32" (ByVal start As Long, ByVal data As Long, ByVal Size As Long) As Long
- Sub test()
- Dim H_T() As Long, Count_T As Long, H As Long, Count As Long, i&, k&
- r = Range("b2:c" & Range("c65536").End(3).Row)
- Count_T = UBound(r) * 1.5
- ReDim H_T(Count_T - 1)
- For i = 1 To UBound(r)
- k = 0
- H = (hash(0, StrPtr(r(i, 1)), LenB(r(i, 1))) And &H7FFFFFFF) Mod Count_T
- Do
- If H_T(H) = 0 Then
- Count = Count + 1
- H_T(H) = Count
- r(H_T(H), 1) = r(i, 1)
- r(H_T(H), 2) = r(i, 2)
- Exit Do
- End If
- If StrComp(r(i, 1), r(H_T(H), 1)) = 0 Then
- r(H_T(H), 2) = r(H_T(H), 2) + r(i, 2)
- Exit Do
- End If
- k = k + 1
- H = (H + k * k) Mod Count_T
- Loop
- Next
- Range("e11").Resize(Count, 2) = r
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|