【问题标题】:VBA Excel Column Sorting Run Time Error 1004VBA Excel 列排序运行时错误 1004
【发布时间】:2019-04-16 16:31:36
【问题描述】:

我想在不使用 select 的情况下对 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

【问题讨论】:

    标签: excel vba


    【解决方案1】:

    试试这个

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多