|
- Sub 按钮1_Click()
- arr = Sheets(1).UsedRange
- Set d = CreateObject("scripting.dictionary")
- Set dt = CreateObject("scripting.dictionary")
- Set dd = CreateObject("scripting.dictionary")
- Sheets(2).Select
- ActiveSheet.UsedRange.Offset(1).ClearContents
- brr = [a1].Resize(UBound(arr), 5)
- Application.ScreenUpdating = False
- a = 2
- For j = UBound(arr) To 2 Step -1
- If Len(arr(j, 16)) > 3 Then
- If Mid(arr(j, 16), 2, 2) * 1 > 20 Then
- str1 = "虚拟出货"
- Else
- str1 = Mid(arr(j, 16), 2, 2)
- End If
- If str1 <> "虚拟出货" Then dt(arr(j, 3)) = dt(arr(j, 3)) + arr(j, 14)
-
- If d.exists(arr(j, 3) & "#" & str1) Then
- r = d(arr(j, 3) & "#" & str1)
- brr(r, 3) = arr(j, 14) + brr(r, 3)
- If InStr(dd(arr(j, 3)), arr(j, 4)) = 0 Then
- dd(arr(j, 3)) = dd(arr(j, 3)) & arr(j, 4) & ","
- End If
- Else
- d(arr(j, 3) & "#" & str1) = a
- brr(a, 1) = arr(j, 3)
- brr(a, 2) = str1
- brr(a, 3) = arr(j, 14)
- If InStr(dd(arr(j, 3)), arr(j, 4)) = 0 Then
- dd(arr(j, 3)) = dd(arr(j, 3)) & arr(j, 4) & ","
- End If
- a = a + 1
- End If
- End If
- Next j
- For j = 2 To a - 1
- If brr(j, 2) <> "虚拟出货" Then
- If dt.exists(brr(j, 1)) Then
- brr(j, 4) = UBound(Split(dd(brr(j, 1)), ","))
- brr(j, 5) = dt(brr(j, 1))
- dt.Remove brr(j, 1)
- dd.Remove brr(j, 1)
- End If
- End If
- Next j
- [a1].Resize(a - 1, 5) = brr
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|