|
- Sub bajifeng() 'by: bajifeng
- 'Thursday, December 20, 2015
- Dim crr()
- fn = Array("1.xls", "2.xls")
- Workbooks.Open ThisWorkbook.Path & "" & fn(0)
- arr = ActiveSheet.UsedRange
- ActiveWorkbook.Close False
- Workbooks.Open ThisWorkbook.Path & "" & fn(1)
- brr = ActiveSheet.UsedRange
- ActiveWorkbook.Close False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- For i = 3 To UBound(arr)
- d1(arr(i, 2)) = arr(i, 6)
- d(arr(i, 2)) = ""
- Next
- k1 = d1.keys
- t1 = d1.items
- For i = 3 To UBound(brr)
- d2(brr(i, 2)) = brr(i, 6)
- d(brr(i, 2)) = ""
- Next
- k2 = d2.keys
- t2 = d2.items
- k = d.keys
- ReDim crr(1 To d.Count, 1 To 4)
- For i = 0 To d.Count - 1
- crr(i + 1, 1) = k(i)
- '1
- For i1 = 0 To d1.Count - 1
- If k(i1) = k(i) Then crr(i + 1, 2) = "'" & t1(i1)
- Next
- '2
- For i2 = 0 To d2.Count - 1
- If k(i2) = k(i) Then crr(i + 1, 3) = "'" & t2(i2)
- Next
- '对比结果
- If crr(i + 1, 2) = crr(i + 1, 3) Then
- crr(i + 1, 4) = "OK"
- Else
- crr(i + 1, 4) = "NG"
- End If
- Next
- [F2:i2].Resize(d.Count) = crr
- End Sub
复制代码 |
|