VBA Excel 列排序运行时错误 1004



我想在不使用选择的情况下对 A 列进行排序,但我一直得到错误按摩,

无法获取范围类的排序属性

'Sort Managers
With QueWS.Columns("A:A")
    .Sort.SortFields.Clear
    .Sort.SortFields.Add Key:=Range("A2:A" & LastRow), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Que").Sort
        .SetRange Range("A1", Cells(LastRow, LastColumn))
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End With

试试这个

With ActiveWorkbook.Worksheets("Que")
    .Sort.SortFields.Clear
    .Sort.SortFields.Add Key:=Range("A1"), _
        SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    With ActiveWorkbook.Worksheets("Que").Sort
        .SetRange Range("A2:A" & LastRow)
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End With

最新更新