|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
参与一下。。。
- Sub ykcbf() '//2024.8.17
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("汇总")
- With sh
- c = .Cells(1, "XFD").End(1).Column
- zrr = .[a1].Resize(, c)
- For j = 2 To UBound(zrr, 2) - 1
- s = zrr(1, j)
- d1(s) = j
- Next
- End With
- ReDim brr(1 To 10000, 1 To c)
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- With sht
- Set Rng = .UsedRange.Find("施工人")
- bt = Rng.Row: col = Rng.Column
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .Cells(bt, "XFD").End(1).Column
- arr = .[a1].Resize(r, c)
- End With
- For i = bt + 1 To UBound(arr)
- If Val(arr(i, 1)) Then
- If InStr(arr(i, 1), "#") = 0 Then
- s = arr(i, col)
- If s <> Empty Then
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- For j = 1 To UBound(arr, 2)
- s1 = arr(bt, j)
- If d1.exists(s1) Then
- brr(m, d1(s1)) = arr(i, j)
- End If
- Next
- Else
- r = d(s)
- For j = 1 To UBound(arr, 2)
- s1 = arr(bt, j)
- If d1.exists(s1) Then
- brr(r, d1(s1)) = brr(r, d1(s1)) + arr(i, j)
- End If
- Next
- End If
- End If
- End If
- End If
- Next
- End If
- Next
- With sh
- .UsedRange.Offset(1).Clear
- .[a2].Resize(m, 11) = brr
- For i = 2 To m + 1
- For j = 1 To 10
- .Cells(i, 11) = Application.Sum(.Cells(i, 2).Resize(, 9))
- Next
- Next
- .Cells(m + 2, 1) = "项目合计"
- For j = 2 To 11
- .Cells(m + 2, j) = Application.Sum(.Cells(2, j).Resize(m))
- Next
- With .[a2].Resize(m + 1, 11)
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Set d = Nothing
- Set d1 = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
3
查看全部评分
-
|