|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
原代码中改二句代码即可。
- Sub ykcbf() '//2024.12.12
- Application.ScreenUpdating = False
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("Sheet1")
- r = .Cells(Rows.Count, "aa").End(3).Row
- c = .UsedRange.Columns.Count
- For i = 5 To r
- s = .Cells(i, 4).Value
- d(s) = d(s) + 1
- If d(s) > 1 Then
- .Cells(i, c + 1).Value = 1
- Else
- .Cells(i, c + 1).Value = 9
- End If
- Next
- Set Rng = .Cells(5, 1).Resize(r - 4, c + 1)
- With Rng
- .Parent.Sort.SortFields.Clear
- .Sort key1:=.Item(c + 1), order1:=2, key2:=.Item(c), order2:=2, Header:=2
- End With
- .Columns(c + 1) = ""
- End With
- Set d = Nothing
- Application.ScreenUpdating = True
- MsgBox "OK!"
- End Sub
复制代码
|
|