尝试在Excel中的VBA中组织/排序数据时遇到语法错误

时间:2013-12-06 09:57:56

标签: excel vba sorting

我正在尝试在Excel中的特定单元格中对某些信息进行排序。这是我到目前为止所拥有的。

Public Sub SplitAddress()


    Dim intRow As Integer
    Dim strCurrentName As String
    Dim strPreviousName As String
    Dim intDuplicate As Integer
    Dim docGuestList As Worksheet
    Dim tblguests As Range

    Set docGuestList = Application.Workbooks("T10-EX-E2D.xls").Worksheets("Consultants")
    Set tblguests = docGuestList.Cells("B2:B17")

    tblguests.Sort excludeheader:=True, _
    fieldnumber:=2, sortfieldtype:=wdSortFieldAlphanumeric, _
    sortorder:=wdSortOrderAscending, _
    fieldnumber2:=3, _
    sortfieldtype2:=wdSortFieldAlphanumeric _
    sortorder2:=wdSortOrderAscending

但是我收到了sortorder2:=wdSortOrderAscending linw的语法错误。我不知道为什么...... :(请帮忙。谢谢。

1 个答案:

答案 0 :(得分:1)

wdSortFieldAlphanumeric之后,您在参数列表中缺少逗号:

fieldnumber2:=3, _
sortfieldtype2:=wdSortFieldAlphanumeric, _
sortorder2:=wdSortOrderAscending