|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下,字典
- Sub ykcbf() '//2024.11.29
- Set d = CreateObject("Scripting.Dictionary")
- r = Cells(Rows.Count, 1).End(3).Row
- arr = [a1].Resize(r, 19)
- On Error Resume Next
- For i = 2 To UBound(arr)
- d.RemoveAll
- If arr(i, 19) <> Empty Then
- If InStr(arr(i, 19), ",") = 0 Then
- If InStr(arr(i, 9), arr(i, 19)) Then
- Cells(i, 9) = Replace(arr(i, 9) & ",", arr(i, 19) & ",", "")
- End If
- Else
- b = Split(arr(i, 19), ",")
- For x = 0 To UBound(b)
- d(b(x)) = ""
- Next
- b = Split(arr(i, 9), ",")
- st = ""
- For x = 0 To UBound(b)
- s = b(x)
- If Not d.exists(s) Then
- st = st & "," & b(x)
- End If
- Next
- Cells(i, 9) = Mid(st, 2)
- End If
- End If
- Next
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|