|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 数据核对()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant
Dim i As Long, r As Long, rs As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Set sh = Sheets("采购记录总表")
With sh
r = .Cells(Rows.Count, 2).End(xlUp).Row
If r < 2 Then MsgBox "采购记录总表为空": End
ar = .Range("a1:o" & r)
End With
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" And Trim(ar(i, 8)) <> "" Then
zd = Trim(ar(i, 2)) & "|" & Trim(ar(i, 8))
d(zd) = i
End If
Next i
With Sheets("送货单")
rs = .Cells(Rows.Count, 3).End(xlUp).Row
If r < 5 Then MsgBox "送货单为空": End
br = .Range("b4:i" & rs)
For i = 2 To UBound(br)
If Trim(br(i, 1)) <> "" And Trim(br(i, 2)) <> "" Then
zd = Trim(br(i, 1)) & "|" & Trim(br(i, 2))
xh = d(zd)
If xh = "" Then
.Cells(i + 3, 1) = "错误"
ElseIf xh <> "" Then
zf_1 = Trim(ar(xh, 10)) & "|" & ar(xh, 11) & "|" & ar(xh, 12) & "|" & ar(xh, 13)
zf_2 = Trim(br(i, 3)) & "|" & br(i, 5) & "|" & br(i, 6) & "|" & br(i, 7)
If Trim(br(i, 3)) <> "杂项费" Then
If zf_1 <> zf_2 Then
.Cells(i + 3, 1) = "错误"
Else
If Trim(sh.Cells(xh, 1)) = "" Then
sh.Cells(xh, 1) = "完成"
Else
.Cells(i + 3, 1) = "错误"
End If
End If
Else
If br(i, 7) <> ar(xh, 14) Then
.Cells(i + 3, 1) = "错误"
End If
End If
End If
End If
Next i
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|