|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST1()
Dim ar, br, cr, dr, i&, j&, k&, dic(1) As New Dictionary
Application.ScreenUpdating = False
ar = [A1].CurrentRegion.Value
br = [J1:N1000].Value
ReDim cr(1 To UBound(ar), 1 To UBound(br, 2) + 1)
cr(1, 1) = "编码"
For j = 1 To UBound(br, 2)
cr(1, j + 1) = br(1, j)
Next j
For i = 2 To UBound(ar)
cr(i, 1) = ar(i, 1)
dr = Split(ar(i, 2), ",")
dic(0).RemoveAll
For j = 0 To UBound(dr): dic(0)(dr(j)) = Empty: Next
For j = 1 To UBound(br, 2) - 1
dic(1).RemoveAll
For k = 2 To UBound(br)
If Len(br(k, j)) Then
If dic(0).exists(br(k, j)) Then
dic(1)(br(k, j)) = Empty
dic(0).Remove br(k, j)
End If
End If
Next k
If dic(1).Count > 0 Then cr(i, j + 1) = Join(dic(1).keys, ",")
Next j
If dic(0).Count > 0 Then cr(i, UBound(cr, 2)) = Join(dic(0).keys, ",")
Next i
[P1].CurrentRegion.ClearContents
[P1].Resize(UBound(cr), UBound(cr, 2)) = cr
Erase dic
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|