按列对数据排序

时间:2019-11-20 15:12:51

标签: excel vba columnsorting

之前的代码运行良好,但是现在我再次面临排序领域的问题。错误(运行时错误424个对象,排序值为空 )

ThisWorkbook.Sheets("Sheet1").Activate
Dim LR As Long
Dim SR As Range

LR = Range("D1").SpecialCells(xlCellTypeLastCell).Row
Set SR = Range("A1:AM" & LR)

With Sort
    .SortFields.Clear
    .SortFields.Add Key:= _
    Range("D1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
    .SetRange.SR
    .Header = xlYes
    .MatchCase = False
    .Orientation = xlTopToBottom
    .SortMethod = xlPinYin
    .Apply
End With

0 个答案:

没有答案