|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。- Sub ykcbf() '//2024.8.5
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- On Error Resume Next
- For Each sht In Sheets
- d.RemoveAll
- If Val(sht.Name) Then
- With sht
- r = .Cells(Rows.Count, "m").End(3).Row
- Arr = .[m1].Resize(r, 3)
- ReDim brr(1 To r, 1 To 3)
- m = 0
- For i = 5 To UBound(Arr)
- s = Trim(Arr(i, 1)) & "|" & Trim(Arr(i, 2))
- If Len(s) > 2 Then
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = Arr(i, 1)
- brr(m, 2) = Arr(i, 2)
- brr(m, 3) = Arr(i, 3)
- Else
- r = d(s)
- brr(r, 3) = brr(r, 3) + Arr(i, 3)
- End If
- End If
- Next
- .[b5:d29] = ""
- .[b5].Resize(m, 3) = brr
- '*****************************************
- r = .Cells(Rows.Count, "w").End(3).Row
- Arr = .[w1].Resize(r, 4)
- ReDim brr(1 To r, 1 To 4)
- m = 0
- For i = 5 To UBound(Arr)
- s = Trim(Arr(i, 1)) & "|" & Trim(Arr(i, 2)) & "|" & Trim(Arr(i, 4))
- If Len(s) > 2 Then
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = Arr(i, 1)
- brr(m, 2) = Arr(i, 2)
- brr(m, 3) = Arr(i, 4)
- brr(m, 4) = Arr(i, 3)
- Else
- r = d(s)
- brr(r, 4) = brr(r, 4) + Arr(i, 3)
- End If
- End If
- Next
- .[b31:d40] = ""
- .[b31].Resize(m, 4) = brr
- '*****************************************
- r = .Cells(Rows.Count, "ab").End(3).Row
- Arr = .[ab1].Resize(r, 4)
- ReDim brr(1 To r, 1 To 4)
- m = 0
- For i = 20 To UBound(Arr)
- s = Trim(Arr(i, 1)) & "|" & Trim(Arr(i, 2)) & "|" & Trim(Arr(i, 3))
- If Len(s) > 2 Then
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = Arr(i, 1)
- brr(m, 2) = Arr(i, 2)
- brr(m, 3) = Arr(i, 3)
- brr(m, 4) = Arr(i, 4)
- Else
- r = d(s)
- brr(r, 4) = brr(r, 4) + Arr(i, 4)
- End If
- End If
- Next
- .[g31:j40] = ""
- .[g31].Resize(m, 4) = brr
- End With
- End If
- Next
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|