|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 按钮3_Click()
Set d = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
Sheets("单价").Select
arr = [a1].CurrentRegion
For j = 2 To UBound(arr)
If d.exists(arr(j, 2)) Then
Set d(arr(j, 2)) = Union(d(arr(j, 2)), Cells(j, 3).Resize(1, 3))
Else
Set d(arr(j, 2)) = Cells(j, 3).Resize(1, 3)
End If
Next j
Sheets("资料").Select
For j = 1 To Cells(1, Columns.Count).End(xlToLeft).Column Step 3
x = Cells(2, j).Value
If d.exists(x) Then
r = Cells(Rows.Count, j).End(3).Row + 1
d(x).Copy Cells(r, j)
End If
Next j
Application.ScreenUpdating = True
End Sub
|
|