|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
参与一下。。。
- Sub ykcbf() '//2024.7.25 表格转换
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- ReDim brr(1 To 10000, 1 To 4)
- m = 1
- brr(1, 1) = "序号": brr(1, 2) = "部件名称"
- brr(1, 3) = "部件详细资料": brr(1, 4) = "数量"
- With Sheets("明细表")
- r = Cells(Rows.Count, 1).End(3).Row
- c = .UsedRange.Columns.Count
- arr = .[a1].Resize(r, c)
- End With
- For j = 3 To UBound(arr, 2)
- For i = 2 To UBound(arr)
- If arr(i, j) <> Empty Then
- s = arr(1, j) & "|" & arr(i, j)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = m - 1
- brr(m, 2) = arr(1, j)
- brr(m, 3) = arr(i, j)
- brr(m, 4) = 1
- Else
- r = d(s)
- brr(r, 4) = brr(r, 4) + 1
- End If
- End If
- Next
- Next
- With Sheets("汇总表")
- .UsedRange.Clear
- .Cells.Interior.ColorIndex = 0
- .[a1].Resize(1, 4).Interior.Color = 49407
- With .[a1].Resize(m, 4)
- .Value = brr
- .Borders.LineStyle = 1
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .EntireRow.AutoFit
- With .Font
- .Name = "微软雅黑"
- .Size = 11
- End With
- End With
- zr = Array(2)
- Call hb(2, 1, 2, zr)
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
评分
-
3
查看全部评分
-
|