2

一連のリストを「名前」という列のアルファベット順に並べ替えようとしています。以下のコードはエラーなしでコンパイルし、エラーなしで実行していますが、リストを並べ替えていません。

誰か助けてもらえますか?

'**
 ' 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
4

1 に答える 1

2

問題は、関数に対してどの引数がどれであるかを指定しなかったことSortFieldsです。その行を以下に変更すると、問題が修正されました。

.SortFields.Add Key:=sort_column, order:=Sort_order
于 2012-11-08T14:57:00.040 に答える