- Sub 宏2()
- Dim arr, d As Object, T$, i&
- Set d = CreateObject("scripting.dictionary")
- arr = Sheet2.[a1].CurrentRegion
- For i = 2 To UBound(arr)
- T = arr(i, 1) & "|" & arr(i, 2)
- d(T) = arr(i, 3)
- Next i
- arr = Sheet1.[a1].CurrentRegion
- For i = 2 To UBound(arr)
- If d.Exists((arr(i, 1)) & "|" & arr(i, 3)) Then
- arr(i, 5) = d((arr(i, 1)) & "|" & arr(i, 3))
- ElseIf d.Exists((arr(i, 1) - 1) & "|" & arr(i, 3)) Then
- arr(i, 5) = d((arr(i, 1) - 1) & "|" & arr(i, 3)) & "(上日数据)"
- Else
- arr(i, 5) = "#NA"
- End If
- Next i
- [a1].Resize(UBound(arr), UBound(arr, 2)) = arr
- End Sub
复制代码 |