|
- Dim arr, ar, d As Object
- Sub BOM()
- Set d = CreateObject("scripting.dictionary")
- arr = [a1].CurrentRegion
- ar = Application.Transpose(Application.Index(arr, , 1))
- Call subtab(Cells(1, "f"), Cells(1, "h"))
- [e3].Resize(UBound(arr, 1), 2) = ""
- [e3].Resize(d.Count, 2) = Application.Transpose(Array(d.keys, d.items))
- End Sub
- Sub subtab(key, r)
- For i = 3 To UBound(arr, 1)
- If arr(i, 1) <> key Then GoTo x
- If UBound(Filter(ar, arr(i, 2), 1)) = -1 Then
- d(arr(i, 2)) = d(arr(i, 2)) + r * arr(i, 3)
- Else
- d(arr(i, 2)) = d(arr(i, 2)) + r * arr(i, 3) 'Èô²»¼ÆËãÖмä¼þɾ³ý´ËÐÐ
- Call subtab(arr(i, 2), r * arr(i, 3))
- End If
- x: Next i
- End Sub
复制代码 |
|