|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
学习一下字典,打扰了
Sub test()
arr = [b2].CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 1 To UBound(arr)
For j = 2 To UBound(arr, 2)
If Not d.exists(arr(i, j)) Then
d(arr(i, j)) = i
Else
ss = Split(d(arr(i, j)), ",")
For k = 0 To UBound(ss)
If i = Val(ss(k)) Then
GoTo x
End If
Next
d(arr(i, j)) = d(arr(i, j)) & "," & i
End If
x:
Next
Next
ReDim brr(1 To UBound(arr), 1 To 1000)
For Each kk In d.keys
m = m + 1
brr(m, 1) = kk
ss = Split(d(kk), ",")
n = 1
For i = 0 To UBound(ss)
n = n + 1
brr(m, n) = ss(i)
Next
If Max < n Then
Max = n
End If
Next
[h4].Resize(m, Max) = brr
End Sub |
评分
-
1
查看全部评分
-
|