我试图通过名为“名称”的列按字母顺序对一系列列表进行排序。下面的代码编译没有错误,运行没有错误,但它没有对列表进行排序。
任何人都可以提供帮助吗?
'**
' Sorts the defined list using the definded parameters
''
Function sort_list(list_name As String, column_name As String, Optional sort_order As String = xlAscending)
Dim list As ListObject ' The list that is to be sorted
Dim sort_column As Range ' The column in the list that is to be used as the sort key
' Set the list and the sort column
Set list = WS_ext.ListObjects(list_name)
Set sort_column = list.ListColumns(column_name).Range
' Sort the list
With list.Sort
.SortFields.Clear
.SortFields.Add sort_column, sort_order
.Header = xlYes
.MatchCase = False
.Apply
End With
End Function