Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sorting 对筛选的范围进行排序_Sorting_Excel_Vba - Fatal编程技术网

Sorting 对筛选的范围进行排序

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

我需要筛选已筛选的此范围。我正在使用下面的代码,但我认为自动筛选是不必要的。然而,如果你移除自动过滤器,我仍然会得到一个 “运行时'438':对象不支持此属性或方法”错误

这是我的密码:

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=我在单独一行代码中指定的范围内的最后一行

不清楚你想达到什么目的。另外,这段代码甚至不会编译。请描述您的输入和预期结果——并发布您的实际代码。