1,特殊条件编号
‘2012-9-3
‘http://club.excelhome.net/forum.php?mod=viewthread&tid=914702&page=1#pid6271907
Sub lqxs()
Dim Arr, i&, j&, jj&, n&, aa, bb, y, x$
Dim d As New Dictionary, k, t, d1 As New Dictionary, t1
Sheet1.Activate
[e31:e5000].ClearContents
Arr = [a1].CurrentRegion
For i = 31 To UBound(Arr)
x = Arr(i, 4)
y = Arr(i, 1) & "|" & Arr(i, 3)
d(x) = d(x) & i & ","
If d1.Exists(x) = False Then Set d1(x) = New Dictionary
d1(x)(y) = d1(x)(y) & i & ","
Next
k = d.keys
t = d.items
For i = 0 To UBound(k)
t(i) = Left(t(i), Len(t(i)) - 1)
n = 0
If InStr(t(i), ",") Then
aa = Split(t(i), ",")
For j = 0 To UBound(aa)
y = Arr(aa(j), 1) & "|" & Arr(aa(j), 3)
n = n + 1
t1 = d1(k(i))(y)
t1 = Left(t1, Len(t1) - 1)
If InStr(t1, ",") Then
bb = Split(t1, ",")
For jj = 0 To UBound(bb)
Cells(bb(jj), 5) = n
Next
j = j + UBound(bb)
Else
Cells(t1, 5) = n
End If
Next
End If
Next
End Sub
评论0