|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
支持 彭总
为了减代码行高 速度有所减慢- Sub 泓()
- Application.ScreenUpdating = False
- [2:2].Replace "Z", "V"
- Set d = CreateObject("scripting.dictionary")
- For n = 1 To 4
- With Sheets(n)
- Cell = .[b2].Resize(.[b65536].End(xlUp).Row - 2, .[iv2].End(xlToLeft).Column - 2)
- For i = 3 To UBound(Cell)
- If Cell(i, 1) = "" Then Cell(i, 1) = Cell(i - 1, 1)
- For j = 3 To UBound(Cell, 2)
- If Cell(1, j) = "" Then Cell(1, j) = Cell(1, j - 1)
- c = Cell(i, 1) & Cell(i, 2) & Cell(1, j) & Cell(2, j)
- If n = 1 Then
- If Not d.exists(c) Then d.Add c, Empty
- Else
- If d.exists(c) Then d(c) = d(c) + Cell(i, j)
- End If
- Next
- Next
- End With
- If n = 1 Then a = UBound(Cell) - 2: b = UBound(Cell, 2) - 2
- Next
- ReDim r(1 To a, 1 To b)
- s = d.Items
- For i = 0 To d.Count - 1
- r(i \ b + 1, i Mod b + 1) = s(i)
- Next
- [2:2].Replace "V", "Z"
- [d4].Resize(a, b) = r
- Set d = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|