|
- Sub 转换()
- Dim arr, i&, j&
- With Worksheets(1)
- arr = .Range("a3", .Cells(Rows.Count, "l").End(xlUp))
- Dim dic As Object
- Dim Key$
- Set dic = CreateObject("scripting.dictionary")
- For i = LBound(arr) + 1 To UBound(arr)
- For j = 7 To 11
- Key = arr(i, 4) & arr(1, j)
- dic(Key) = dic(Key) + arr(i, j)
- Next
- Next
- If dic.Count > 0 Then
- Application.ScreenUpdating = False
- .Range("n3").Resize(, 2) = Array("款式编号", "库存数量")
- .Range("n4").Resize(dic.Count) = Application.Transpose(dic.keys)
- .Range("o4").Resize(dic.Count) = Application.Transpose(dic.items)
- Application.ScreenUpdating = True
- MsgBox "合并完成", vbInformation + vbOKOnly
- End If
- End With
- End Sub
复制代码 |
|