|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
如图:AB为源数据,因附件不能超2M,所以行数少了很多,行数超1W就得2分钟时间,
C-E为生成项,见代码,求大神给优化下
工作簿1.rar
(64.73 KB, 下载次数: 11)
Sub 核查()
Set d = CreateObject("scripting.dictionary")
Set Z = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
Arr = [a1].CurrentRegion
Columns("c:e") = ""
ii = 1
Cells(1, 3) = "两者关系"
Cells(1, 4) = "双向去重"
Cells(1, 5) = "双向去重"
For j = 2 To UBound(Arr)
If Z.exists(Arr(j, 1) & "#" & Arr(j, 2)) Then
Else
Z(Arr(j, 1) & "#" & Arr(j, 2)) = j
End If
If d.exists(Arr(j, 1) & "#" & Arr(j, 2)) Or d.exists(Arr(j, 2) & "#" & Arr(j, 1)) Then
Else
ii = ii + 1
d(Arr(j, 1) & "#" & Arr(j, 2)) = j
Cells(ii, 4) = Arr(j, 1)
Cells(ii, 5) = Arr(j, 2)
End If
Next j
For x = 2 To UBound(Arr)
If Z.exists(Arr(x, 1) & "#" & Arr(x, 2)) And Z.exists(Arr(x, 2) & "#" & Arr(x, 1)) Then
Cells(x, 3) = "双方向添加"
Else
Cells(x, 3) = "单方向添加"
End If
Next x
Application.ScreenUpdating = True
End Sub
|
|