|
楼主 |
发表于 2023-6-17 21:44
|
显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub ssjss() '2023.6.17 wzq
- Dim ar, i&, r&, dic As Object, T
- Set dic = CreateObject("Scripting.Dictionary")
- Set dic1 = CreateObject("Scripting.Dictionary")
- With Sheets("动态表").[A1].CurrentRegion
- ar = .Resize(30000)
- r = .Rows.Count
- For i = 2 To r
- dic1(ar(i, 1)) = Array(ar(i, 2), ar(i, 3))
- Next i
- End With
- With Sheets("原始表").[A1].CurrentRegion
- ar = .Resize(30000)
- r = .Rows.Count
- For i = 2 To r: dic(ar(i, 4)) = i: Next i
- End With
- For i = 2 To r
- If dic1.exists(ar(i, 4)) Then
- If dic1(ar(i, 4))(0) > ar(i, 10) Then
- ar(i, 13) = "增加"
- ElseIf dic1(ar(i, 4))(0) < ar(i, 10) Then
- ar(i, 13) = "减少"
- End If
- ar(i, 10) = dic1(ar(i, 4))(0)
- ar(i, 11) = dic1(ar(i, 4))(1)
- Else
- ar(i, 13) = "核销"
- End If
- Next
- For Each T In dic1.keys
- If Not dic.exists(T) Then
- ar(i, 4) = T
- ar(i, 10) = dic1(T)(0)
- ar(i, 11) = dic1(T)(1)
- ar(i, 13) = "新增"
- i = i + 1
- End If
- Next
- Sheets("原始表").[A1].Resize(i, UBound(ar, 2)) = ""
- Sheets("原始表").[A1].Resize(i, UBound(ar, 2)) = ar
- Set dic = Nothing: Set dic = Nothing
- End Sub
复制代码
|
|