|
- Sub 提取异同()
- Dim a1, a2, arr1, arr2
- Set 一独有 = CreateObject("scripting.dictionary")
- Set 二独有 = CreateObject("scripting.dictionary")
- Set 都有 = CreateObject("scripting.dictionary")
- 数据1 = Range("a1").CurrentRegion
- 数据2 = Range("e1").CurrentRegion
- For i = 3 To UBound(数据1)
- a1 = 数据1(i, 1) & 数据1(i, 2) & 数据1(i, 3)
- For j = 3 To UBound(数据2)
- a2 = 数据2(j, 1) & 数据2(j, 2) & 数据2(j, 3)
- If a1 = a2 Then 都有(a1) = Array(数据1(i, 1), 数据1(i, 2), 数据1(i, 3)): GoTo 100
- Next j
- 一独有(a1) = Array(数据1(i, 1), 数据1(i, 2), 数据1(i, 3))
- 100:
- Next i
- For j = 3 To UBound(数据2)
- a2 = 数据2(j, 1) & 数据2(j, 2) & 数据2(j, 3)
- For i = 3 To UBound(数据1)
- a1 = 数据1(i, 1) & 数据1(i, 2) & 数据1(i, 3)
- If a2 = a1 Then GoTo 200
- Next i
- 二独有(a2) = Array(数据2(j, 1), 数据2(j, 2), 数据2(j, 3))
- 200:
- Next j
- If 一独有.Count > 0 Then
- [i6].Resize(一独有.Count, 3) = Application.Transpose(Application.Transpose(一独有.items))
- Else
- [i6] = "无"
- End If
- If 二独有.Count > 0 Then
- [m6].Resize(二独有.Count, 3) = Application.Transpose(Application.Transpose(二独有.items))
- Else
- [m6] = "无"
- End If
- If 都有.Count > 0 Then
- [q6].Resize(都有.Count, 3) = Application.Transpose(Application.Transpose(都有.items))
- Else
- [q6] = "无"
- End If
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|