|
- Sub sdyt()
- Set d = CreateObject("scripting.dictionary")
- arr = ActiveSheet.Range("a2").CurrentRegion
- For i = 3 To UBound(arr)
- s = arr(i, 2) & "|" & arr(i, 3)
- d(s) = "原表"
- Next
- brr = ActiveSheet.Range("e2").CurrentRegion
- For i = 3 To UBound(brr)
- s1 = brr(i, 2) & "|" & brr(i, 3) '问题要自动加入字典,不经判断
- If Not d.Exists(s1) Then '判断失效导致字典条目标记错误
- d(s1) = "新表"
- Else
- d(s) = "共有"
- End If
- Next
- i = 3: n = 3: m = 3
- For Each k In d.Keys
- If d(k) = "原表" Then
- ActiveSheet.Cells(i, "j").Resize(, 2) = Split(k, "|")
- i = i + 1
- ElseIf d(k) = "新表" Then
- ActiveSheet.Cells(n, "n").Resize(, 2) = Split(k, "|")
- n = n + 1
- ElseIf d(k) = "共有" Then
- ActiveSheet.Cells(n, "q").Resize(, 2) = Split(k, "|")
- n = n + 1
- End If
- Next
- Set d = Nothing
- End Sub
复制代码 判断两列数据,用字典的条目标记,过程中出现判断错误。
|
|