|
Sub test()
Set d = CreateObject("scripting.dictionary")
arr = Sheets("数据表").UsedRange
r = 3
For j = 4 To UBound(arr)
If Len(arr(j, 2)) > 0 Then
str1 = ""
For i = 2 To 9
str1 = str1 & "#" & arr(j, i)
Next i
If Not d.exists(str1) Then
r = r + 1
d(str1) = r
For i = 2 To UBound(arr, 2)
arr(r, i) = arr(j, i)
Next i
arr(r, 1) = r - 3
arr(r, 10) = arr(r, 10) & arr(r, 11) & "斤"
Else
x = d(str1)
arr(x, 10) = arr(x, 10) & "、" & arr(j, 10) & arr(j, 11) & "斤"
arr(x, 11) = arr(x, 11) + arr(j, 11)
End If
End If
Next j
Sheets("结果").[a1].Resize(r, UBound(arr, 2)) = arr
End Sub
|
|