|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 hhjjpp 于 2016-7-14 09:54 编辑
数据量不是特大,可以考虑简单的split:
- Sub 去重()
- Dim i&, j%, arr
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- arr = Sheet1.Range("A2:A" & Sheet1.[A65536].End(3).Row)
- j = 1
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- d(arr(i, 1)) = d(arr(j, 1)) & "," & arr(i, 1) & "," & arr(i, 1)
- j = i
- End If
- Next i
- Sheet1.Range("E2:E250").ClearContents
- [e2].Resize(d.Count * 2, 1) = Application.Transpose(Split(Mid(d(arr(j, 1)), 2, 999999), ",")) '注意split结果与字典keys方法一样得到的是行向分布的一维数组
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|