|
楼主 |
发表于 2024-10-27 11:47
|
显示全部楼层
你好,认真学习了你的代码,受益匪浅。把A列的不重复值所对应的B列不重复值放在一个单元格,用\连接,但是首个\怎么去除不了。我这里用mid 从第2个开始取1000,但是没用。请指教,谢谢- Sub test()
- Dim dic, arr(), brr(), i, j, k, m, n, s, ss, t, x
- Set dic = CreateObject("scripting.dictionary")
- arr = Range("a1").CurrentRegion
- ReDim brr(1 To UBound(arr), 1 To 2)
- For i = 2 To UBound(arr)
- s = arr(i, 1): ss = arr(i, 2)
- If Not dic.exists(s) Then Set dic(s) = CreateObject("scripting.dictionary")
- dic(s)(ss) = i
- Next i
- For Each k In dic.keys
- m = m + 1
- brr(m, 1) = k
-
- For Each t In dic(k).keys
-
- brr(m, 2) = brr(m, 2) & "" & t
- x = brr(m, 2)
- x = Mid(x, 2, 10000)
- Next t
-
- Next k
- Range("e2").Resize(m, 2) = brr
- End Sub
复制代码 |
|