|
为什么运算一次结果就会重复增加一次数据到表里?而且是成倍数增加到表里,求大神帮忙看一下
Sub 价格统计表()
Dim a, b, c, d, i, j
Dim arr, brr, crr
Dim dic
arr = Sheets("BOM表").[a1].CurrentRegion
Set dic = CreateObject("scripting.dictionary")
Sheets("价格统计表").Range("a1").AutoFilter
For a = 8 To UBound(arr, 2) Step 4
i = arr(1, a) & arr(2, a) & arr(3, a) & arr(4, a)
dic(i) = Array(arr(6, a + 1), arr(6, a + 3))
Next
ReDim crr(1000, 6)
brr = Sheets("价格统计表").[a1].CurrentRegion
For b = 2 To UBound(brr)
j = brr(b, 1) & brr(b, 2) & brr(b, 3) & brr(b, 4)
If dic.exists(j) Then
brr(b, 5) = dic(j)(0)
brr(b, 6) = dic(j)(1)
Else
c = c + 1
For d = 1 To 6
crr(c - 1, d - 1) = brr(b, d)
Next
End If
Next
Sheets("价格统计表").[a:q].NumberFormat = "@"
Sheets("价格统计表").[a1].Resize(UBound(brr), UBound(brr, 2)) = brr
Sheets("价格统计表").Cells(UBound(brr) + 1, 1).Resize(c, 6) = crr
Sheets("价格统计表").Range("a1").AutoFilter
End Sub
|
|