|
回复8楼,你是想把图2的数据汇总到图1吧?如果是这样,那你的箭头是不是画反了?
下面这段代码是把图2(NOR-CSSL 表)的数据汇总写到图1(出货 表):
Sub test()
Set ds = CreateObject("scripting.dictionary")
arr = Sheets("NOR-CSSL").Range("A1").CurrentRegion.Value
ReDim brr(1 To UBound(arr) + 1, 1 To 5)
For i = 2 To UBound(arr)
sss = arr(i, 1) & "|" & arr(i, 6)
If sss <> "" Then
If Not ds.exists(sss) Then
m = ds.Count + 1
ds(sss) = m
brr(m, 1) = arr(i, 1)
brr(m, 2) = arr(i, 6)
brr(m, 3) = arr(i, 2)
End If
m = ds(sss)
brr(m, 4) = brr(m, 4) + arr(i, 3)
tt = tt + arr(i, 3)
End If
Next
brr(ds.Count + 1, 1) = "总计"
brr(ds.Count + 1, 4) = tt
With Sheets("出货")
.Range("A1").CurrentRegion.Offset(1).ClearContents
.Range("A2").Resize(ds.Count + 1, 5) = brr
End With
End Sub
|
|