|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
我重新上传一个代码,你再试试。
要等一下,要审核。
- Sub ykcbf() '//2024.3.8
- Dim arr, brr, d
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("汇总")
- For x = 1 To 8
- s = sh.Cells(1, x)
- d(s) = x
- Next
- ReDim brr(1 To 100000, 1 To 8)
- On Error Resume Next
- For Each sht In Sheets
- If sht.Name <> sh.Name Then
- arr = sht.UsedRange
- For i = 2 To UBound(arr)
- If arr(i, 1) <> Empty Then
- m = m + 1
- For j = 1 To UBound(arr, 2)
- s = arr(1, j)
- If d.exists(s) Then
- brr(m, d(s)) = arr(i, j)
- End If
- Next
- End If
- Next
- End If
- Next
- With sh
- .UsedRange.Offset(1).Clear
- With .[a2].Resize(m, 8)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- Set d = Nothing
- MsgBox "OK!"
- End Sub
复制代码
|
|