|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
晚上拷回家做的- Const r = 4
- Sub cc()
- Dim i&, j&, k&, m&, n&, x&, rng, Arr, brr, Sh As Worksheet, d As Object
- Application.ScreenUpdating = False
- Range(Cells(2, 2), Cells(2, 100)).Replace "Z", "V"
- rng = [b1].CurrentRegion
- For i = r To UBound(rng) - 1
- If rng(i, 1) = "" Then rng(i, 1) = rng(i - 1, 1)
- Next
- For i = r To UBound(rng, 2) - 1
- If rng(2, i) = "" Then rng(2, i) = rng(2, i - 1)
- Next
- For Each Sh In ThisWorkbook.Sheets
- If Sh.Name <> "总表" Then
- t = 0
- Set d = CreateObject("scripting.dictionary")
- Arr = Sh.[b1].CurrentRegion
- For i = r To UBound(Arr) - 1
- If Arr(i, 1) = "" Then Arr(i, 1) = Arr(i - 1, 1)
- Next
- For i = r To UBound(Arr, 2)
- If Arr(2, i - 1) = "" Then Arr(2, i - 1) = Arr(2, i - 2)
- d(Arr(2, i - 1) & Arr(3, i - 1)) = ""
- Next
- n = 0
- For k = r To UBound(rng, 2) - 1
- m = 0
- x = 0
- y = 0
- Do While t < UBound(rng, 2) - 2
- j = j + 1
- If d.exists(rng(2, t + 2) & rng(3, t + 2)) Then
- If j = UBound(rng) - 3 Then m = 0: n = n + 1: GoTo 0
- m = m + 1
- If rng(r + m - 1, 1) & rng(r + m - 1, 2) = Arr(r + x, 1) & Arr(r + x, 2) Then
- y = y + 1
- If rng(2, t + 2) & rng(3, t + 2) = Arr(2, r + n - 1) & Arr(3, r + n - 1) Then
- rng(m + 3, t + 2) = rng(m + 3, t + 2) + Arr(3 + y, r + n - 1)
- 'Cells(m + 3, t + 3) = Cells(m + 3, t + 3) + Arr(3 + y, r + n - 1)
- x = x + 1
- End If
- End If
- Else
- 0
- t = t + 1
- x = 0
- j = 0
- y = 0
- End If
- Loop
- n = n + 1
- If n = UBound(Arr, 2) Then n = 0
- Next
- End If
- Set d = Nothing
- Next
- [b1].Resize(UBound(rng) - 1, UBound(rng, 2) - 1) = rng
- Range(Cells(2, 2), Cells(2, 100)).Replace "V", "Z"
- Application.ScreenUpdating = True
- End Sub
复制代码
销量汇总end.rar
(21.31 KB, 下载次数: 286)
|
评分
-
1
查看全部评分
-
|