|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
VBA法
Option Explicit
Sub TEST6()
Dim ar, cr, i&, j&, dic As Object
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = Range("A1", Cells(Rows.Count, "B").End(xlUp))
For i = 1 To UBound(ar)
cr = Split(ar(i, 2), ",")
dic.RemoveAll
For j = 0 To UBound(cr)
dic(cr(j)) = Empty
Next j
cr = Split(ar(i, 1), ",")
For j = 0 To UBound(cr)
If dic.exists(cr(j)) Then dic.Remove cr(j)
Next j
ar(i, 1) = Join(dic.keys, ",")
Next i
Columns("C").Clear
[C1].Resize(UBound(ar)) = ar
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
|