Sorting 对筛选的范围进行排序
我需要筛选已筛选的此范围。我正在使用下面的代码,但我认为自动筛选是不必要的。然而,如果你移除自动过滤器,我仍然会得到一个 “运行时'438':对象不支持此属性或方法”错误 这是我的密码:Sorting 对筛选的范围进行排序,sorting,excel,vba,Sorting,Excel,Vba,我需要筛选已筛选的此范围。我正在使用下面的代码,但我认为自动筛选是不必要的。然而,如果你移除自动过滤器,我仍然会得到一个 “运行时'438':对象不支持此属性或方法”错误 这是我的密码: Range(cells(1,1),cells(9,5).select selection.autofilter activesheet.selection.autofilter.sort.sortfields.clear activesheet.selection.autofilter.sort.sortfie
Range(cells(1,1),cells(9,5).select
selection.autofilter
activesheet.selection.autofilter.sort.sortfields.clear
activesheet.selection.autofilter.sort.sortfields. _
add key:=range("a8"), sorton:=xlsortonvalues, order:=xldescending, _
dataoption:=xlsortnormal
with activesheet.autofilter.sort
.header=xlYes
.matchcase=false
.orienation=xltoptobottom
.sortmethod=xlPinYin
.apply
end with
抱歉耽搁了,伙计们。此外,我应该更明确地说明我想从代码中得到什么。我真的只是想复制一系列的单元格。我能够使用我录制的宏中的代码。以下是最终有效的代码:
Range(cells(FR,1),cells(LastRow,5)).select
activeworkbook.worksheets("TR_Tracking").sort.sortfields.clear
activeworkbook.worksheets("TR_Tracking").sort.sortfields.add key:=range( _
cells(FR,1),cells(lastrow,1)),sorton:=xlsortonvalues,order:=xlascending, dataoption:= _
xlsortnormal
with activeworkbook.worksheets("TR_Tracking").sort
.setrange range(cells((FR-1),1),cells(LastRow,5))
.header=xlYes
.matchcase= false
.orientation =xltoptobottom
.sortmethod=xlpinyin
.apply
end with
FR=第一行,LastRow=我在单独一行代码中指定的范围内的最后一行 不清楚你想达到什么目的。另外,这段代码甚至不会编译。请描述您的输入和预期结果——并发布您的实际代码。