|
- Sub 测试19()
- Dim arr, brr, a, b, c
- Application.ScreenUpdating = False
- Sheets(2).Rows(3 & ":" & Sheets(2).UsedRange.Rows.Count).ClearContents
- Set d = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- arr = Sheets(1).UsedRange
- For i = 2 To UBound(arr)
- d(arr(i, 1) & arr(i, 3)) = arr(i, 3)
- d2(arr(i, 1) & arr(i, 3) & arr(i, 2)) = d2(arr(i, 1) & arr(i, 3) & arr(i, 2)) + arr(i, 4)
- Next
- Sheets(2).Range("d3").Resize(d.Count) = WorksheetFunction.Transpose(d.Keys)
- brr = Sheets(2).UsedRange
- For i = 3 To UBound(brr)
- If brr(i, 4) <> "" Then
- a = Len(brr(i, 4))
- b = Right(brr(i, 4), 1): c = Left(brr(i, 4), a - 1)
- End If
- For u = 5 To 7
- If brr(i, 4) <> "" Then
- brr(i, 4) = c
- If brr(2, u) = b Then brr(i, u) = b: Exit For
- Else: Exit For
- End If
- Next
- Next
- For i = 3 To UBound(brr)
- For u = 5 To 7
- For p = 8 To UBound(brr, 2)
- If brr(i, u) <> "" Then
- If d2.exists(brr(i, 4) & brr(2, u) & brr(2, p)) Then
- brr(i, p) = d2(brr(i, 4) & brr(2, u) & brr(2, p))
- End If
- End If
- Next
- Next
- Next
- Sheets(2).Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
- Application.ScreenUpdating = True
- Set arr = Nothing
- Set brr = Nothing
- End Sub
复制代码
|
|