|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。。
- Sub ykcbf() '//2024.8.25
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("表1")
- With sh
- r = .Cells(Rows.Count, 1).End(3).Row
- c1 = .Cells(1, "XFD").End(1).Column
- arr = .[a1].Resize(r, c1)
- ReDim crr(1 To 10000, 1 To c1)
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 1) & "|" & arr(i, 2)
- d(s) = i
- Next
- brr = Sheets("表2").UsedRange
- On Error Resume Next
- With sh
- For i = 2 To UBound(brr)
- s = brr(i, 1) & "|" & brr(i, 2)
- If d.exists(s) Then
- m = m + 1
- For j = 1 To UBound(arr)
- crr(m, j) = arr(d(s), j)
- Next
- crr(m, 5) = crr(m, 5) + brr(i, 4)
- crr(m, 6) = crr(m, 6) + brr(i, 5)
- Else
- m = m + 1
- crr(m, 1) = brr(i, 1)
- crr(m, 2) = brr(i, 2)
- crr(m, 5) = brr(i, 4)
- crr(m, 6) = brr(i, 5)
- End If
- Next
- .[a2].Resize(m, c1) = crr
- End With
- Set d = Nothing
- Application.ScreenUpdating = False
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
2
查看全部评分
-
|