|
另写了一个基本以数组为运算过程的代码- Sub kagawa2()
- Dim i%, j%
-
- m = [a65536].End(3).Row
- arr = [b1].Resize(m, 2)
- ReDim brr(2 To m, 3)
-
- Set d = CreateObject("Scripting.Dictionary")
- For i = 2 To m
- If arr(i, 1) <> 2 And arr(i, 1) <> 5 And arr(i, 2) <> "" Then
- t = d(arr(i, 2))
- If t = "" Then
- brr(i, 2) = i
- d(arr(i, 2)) = i
- Else
- brr(i, 2) = t
- brr(t, 3) = brr(t, 3) + 1
- End If
- End If
- Next
-
- For i = 2 To m
- If brr(i, 2) <> "" Then
- If brr(brr(i, 2), 3) > 0 Then
- brr(i, 0) = brr(i, 2)
- brr(i, 1) = brr(brr(i, 2), 3) + 1
- End If
- End If
- Next
-
- [d2].Resize(m - 1, 2) = brr
-
- End Sub
复制代码 请看附件。
赵刚版主代码也顺便按楼主要求做了修改。
三种代码速度都差不多。……要看楼主的数据量了。
|
|