|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 ykcbf1100 于 2024-2-8 22:24 编辑
参与一下。。。- Sub ykcbf2() '//2024.2.8
- Dim arr, d
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- Set Sh = ThisWorkbook.Sheets("汇总")
- ReDim brr(1 To 10000, 1 To 100)
- m = 1: n = 3
- For Each Sht In Sheets
- If Sht.Name <> Sh.Name Then
- With Sht
- r = .Cells(.Rows.Count, "a").End(xlUp).Row
- arr = .[a1].Resize(r, 4)
- fn = .Name
- End With
- For i = 2 To UBound(arr)
- s = arr(i, 1)
- If Not d.Exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = fn
- brr(m, 2) = s
- brr(m, 3) = arr(i, 2)
- End If
- s = arr(i, 3)
- If Not d.Exists(s) Then
- n = n + 1
- d(s) = n
- brr(1, n) = s
- End If
- r = d(arr(i, 1)): c = d(arr(i, 3))
- brr(r, c) = brr(r, c) + arr(i, 4)
- Next
- End If
- Next
- With Sh
- .Cells.Clear
- With .[a1].Resize(m, n)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- .[a1:c1] = Array("表名", "姓名", "性别")
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|