|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
练习一下。。。- Sub ykcbf() '//2024.7.21 表格汇总
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- ReDim brr(1 To 10000, 1 To 100)
- m = 2: n = 1
- On Error Resume Next
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- brr(1, 1) = arr(1, 6)
- brr(1, 2) = arr(1, 5)
- For i = 2 To UBound(arr)
- s = arr(i, 7)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = s
- End If
- r = d(arr(i, 7))
- s = arr(i, 5)
- If Not d.exists(s) Then
- n = n + 1
- d(s) = n
- brr(2, n) = s
- End If
- c = d(arr(i, 5))
- brr(r, c) = brr(r, c) + arr(i, 8)
- Next
- n = n + 1
- brr(1, n) = "备注"
- With Sheets("Sheet2")
- .UsedRange.Clear
- .Cells.Interior.ColorIndex = 0
- .[a1].Resize(2, n).Interior.Color = 49407
- .[a3].Resize(m - 2, 1).Interior.Color = 5296274
- With .[a1].Resize(m, n)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- .[a1].Resize(2).Merge
- .[b1].Resize(, n - 2).Merge
- .Cells(1, n).Resize(2).Merge
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|