|
楼主 |
发表于 2019-12-25 12:14
|
显示全部楼层
已解决
Sub 核对数据()
Dim r, rp, col, y As Byte
Dim d, dr As Object
Dim a, b, c, f, g, h As Byte
Application.FindFormat.Clear
a = Cells.Find("源数据", lookat:=xlWhole).Column
b = Cells.Find("Click", lookat:=xlWhole).Column
c = Cells.Find("Spend", lookat:=xlWhole).Column
f = Cells.Find("Campaigns", lookat:=xlWhole).Column
g = Cells.Find("Clicks", lookat:=xlWhole).Column
h = Cells.Find("Spend(USD)", lookat:=xlWhole).Column
Cells.Interior.Color = xlNone
r = Cells(Rows.Count, f).End(xlUp).Row
rp = Cells(Rows.Count, a).End(xlUp).Row
Set d = CreateObject("scripting.dictionary")
Set dr = CreateObject("scripting.dictionary")
For y = 2 To r
If InStr(Cells(y, h), ".") Then Cells(y, h) = Split(Cells(y, h).Value, ".")(0) & "." & Split(Cells(y, h).Value, ".")(1)
d(Cells(y, f).Value) = Cells(y, g).Value
dr(Cells(y, f).Value) = Cells(y, h).Value
Next
For y = 2 To rp - 1
If InStr(Cells(y, c), ".") Then Cells(y, c) = Split(Cells(y, c).Value, ".")(0) & "." & Split(Cells(y, c).Value, ".")(1)
If d(Cells(y, a).Value) <> Cells(y, b).Value Then Cells(y, a).Interior.Color = vbYellow
If dr(Cells(y, a).Value) <> Cells(y, c).Value Then Cells(y, a).Interior.Color = vbYellow
Next
MsgBox r & Chr(10) & rp
End Sub
|
|