|
全表自动生成
- Sub ykcbf2() '//2025.1.28
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set sh = ThisWorkbook.Sheets("结果")
- ReDim brr(1 To 10000, 1 To 100)
- bt = 1 '//标题行
- m = bt: n = 1
- On Error Resume Next
- With Sheets("Sheet1")
- zrr = .[r1].CurrentRegion
- arr = .[a1].CurrentRegion
- End With
- brr(1, 1) = arr(1, 1)
- For i = 2 To UBound(zrr)
- n = n + 1
- brr(1, n) = zrr(i, 1)
- Next
- For i = 2 To UBound(arr)
- For x = 2 To UBound(zrr)
- If x = UBound(zrr) Then r1 = zrr(UBound(zrr), 2): r2 = 1000
- r1 = zrr(x, 2): r2 = zrr(x + 1, 2)
- If arr(i, 15) >= r1 And arr(i, 15) < r2 Then c = x: Exit For
- Next
- s = arr(i, 1)
- If Not d.exists(s) Then
- m = m + 1
- d(s) = m
- brr(m, 1) = arr(i, 1)
- End If
- r = d(arr(i, 1))
- brr(r, c) = brr(r, c) + 1
- Next
- With sh
- .UsedRange.Clear
- .Cells.Interior.ColorIndex = 0
- .[a1].Resize(bt, n).Interior.Color = 49407
- .[a2].Resize(m - bt, 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
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|