|
Sub 对账()
Dim i, j, k, m, n, irow, irow1
Dim arr, brr
Dim d1 As Object
Dim d2 As Object
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
irow = Sheets("纸板出入库列表1").[J65536].End(xlUp).Row
arr = Sheets("纸板出入库列表1").Range("a1:j" & irow)
For i = 6 To UBound(arr)
If arr(i, 7) <> "" Then
d1(arr(i, 7)) = d1(arr(i, 7)) + arr(i, 10)
End If
Next
irow1 = Sheets("纸板出入库列表2").[J65536].End(xlUp).Row
brr = Sheets("纸板出入库列表2").Range("a1:j" & irow1)
For j = 3 To UBound(brr)
If brr(j, 7) <> "" Then
d2(brr(j, 7)) = d2(brr(j, 7)) + brr(j, 10)
End If
Next
For Each k In d1.keys
d1(k) = WorksheetFunction.Round(d1(k), 1)
d2(k) = WorksheetFunction.Round(d2(k), 1)
If d1(k) = d2(k) Then
For m = 6 To UBound(arr)
If arr(m, 7) = k Then
Sheets("纸板出入库列表1").Cells(m, 7).Font.Color = vbRed
Sheets("纸板出入库列表1").Cells(m, 10).Font.Color = vbRed
End If
Next
For n = 3 To UBound(brr)
If brr(n, 7) = k Then
Sheets("纸板出入库列表2").Cells(n, 7).Font.Color = vbRed
Sheets("纸板出入库列表2").Cells(n, 10).Font.Color = vbRed
End If
Next
End If
Next
MsgBox "ok"
End Sub |
|