|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Option Explicit
Sub TEST6()
Dim ar, br, i&, dic As Object, iPosRow&
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = Worksheets(1).[A1].CurrentRegion.Value
For i = 2 To UBound(ar)
If Not dic.exists(ar(i, 2)) Then
dic(ar(i, 2)) = i
End If
Next i
br = Worksheets(5).[A1].CurrentRegion.Value
For i = 2 To UBound(br) - 2
If dic.exists(br(i, 1)) Then
iPosRow = dic(br(i, 1))
ar(iPosRow, 3) = ar(iPosRow, 3) + br(i, 3)
End If
Next i
With Worksheets(1)
.[A1].Resize(UBound(ar), UBound(ar, 2)) = ar
.Activate
End With
Set dic = Nothing
Application.ScreenUpdating = True
Beep
End Sub
|
评分
-
1
查看全部评分
-
|