|
本帖最后由 ykcbf1100 于 2024-1-25 14:27 编辑
参与一下,代码以附件为准。- Sub ykcbf() '//2024.1.25
- Dim arr, brr
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- r = Me.Cells(Rows.Count, "a").End(xlUp).Row
- Set Rng = Me.Range("a2:ar" & r)
- With Rng
- .Parent.Sort.SortFields.Clear
- .Sort Key1:=.Item(1), Order1:=1, Key2:=.Item(2), Order2:=1, Header:=2
- End With
- arr = Me.Range("a1:ar" & r)
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2) + 1)
- For i = 2 To UBound(arr)
- m = m + 1
- brr(m, 1) = m
- For j = 1 To UBound(arr, 2)
- brr(m, j + 1) = arr(i, j)
- Next
- Next
- Me.[av2:vh10000].ClearContents
- With Me.[av2].Resize(m, UBound(brr, 2))
- .Value = brr
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- .Borders.LineStyle = 1
- End With
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|