|
请测试。
- Sub test()
- Dim dic As Object, d As Object
- Dim m%, Arr, i%, j%
- Dim Str As String
- Application.ScreenUpdating = False
- Set dic = CreateObject("scripting.dictionary")
- Set d = CreateObject("scripting.dictionary")
- m = [A65536].End(xlUp).Row
- Arr = Range("F1:J" & m)
- '将单据号和贷方合成字符串,装入字典
- For i = 2 To UBound(Arr, 1)
- If Arr(i, 2) = "" Then
- Str = Arr(i, 1) & Arr(i, 3)
- dic(Str) = ""
- End If
- Next
- '正向查找
- For i = 2 To UBound(Arr, 1)
- If Arr(i, 2) <> "" Then
- Str = Arr(i, 1) & Arr(i, 2)
- If dic.exists(Str) Then
- Cells(i, "I") = 22
- End If
- End If
- Next
- '将单据号和借方合成字符串,装入字典
- For i = 2 To UBound(Arr, 1)
- If Arr(i, 2) <> "" Then
- Str = Arr(i, 1) & Arr(i, 2)
- d(Str) = ""
- End If
- Next
- '反向查找
- For i = 2 To UBound(Arr, 1)
- If Arr(i, 2) = "" Then
- Str = Arr(i, 1) & Arr(i, 3)
- If d.exists(Str) Then
- Cells(i, "I") = 22
- End If
- End If
- Next
- '删除相同单据号的借方和贷方 行
- For i = 2 To UBound(Arr, 1)
- If Cells(i, "I") = 22 Then
- Rows(i).Delete Shift:=xlUp
- i = 2
- End If
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|