Sub 自定义按行排序()
Dim n
Dim rng As Range
Set rng = Range("H1:H" & Cells(Rows.Count, "H").End(xlUp).Row)
'先清除掉添加过的自定义序列
Application.DeleteCustomList (12)
'添加自定义序列
Application.AddCustomList (rng)
'获取自定义序列在Excel选项中的序号,等排序完成后清除掉这个自定义序列
n = Application.CustomListCount
'Header标题设置为无标题,Orientation设置为按行排序,意思是按照第一行B1:E1作为关键字排序
Range("B1:E3").Sort key1:=[B1], order1:=xlAscending, Header:=xlNo, ordercustom:=n + 1, MatchCase:=False, Orientation:=xlSortRows
Application.DeleteCustomList (n)
End Sub
自定义按行排序
于 2023-08-19 16:35:56 首次发布