Range("A1:G15").Sort Key1:=Columns("E"), order1:=xlDescending, Key2:=Columns("G"), order2:=xlDescending, Header:=xlYes 在不违反Key1(智力)降序的情况下设置Key2(魅力)降序,我们就得到这样的表格:可以发现周瑜因为魅力值高于司马懿,所以跑到了司马懿的上面。事实上我们还可以设置更次一级...
DataOption3 As XlSortDataOption) 说明: l 所有参数均可选。 l 参数Key1、Key2、Key3指定排序字段,确定要排序的值,但参数Key2、Key3不能用于排序数据透视表。 l 参数Order1、Order2、Order3,分别确定参数Key1、Key2、Key3指定值的排序顺序,相应的常量值是xlDescending或者xlAscending(默认)。 l 参数Type,指...
参数Key1、Key2、Key3指定排序字段,确定要排序的值,但参数Key2、Key3不能用于排序数据透视表。 参数Order1、Order2、Order3,分别确定参数Key1、Key2、Key3指定值的排序顺序,相应的常量值是xlDescending或者xlAscending(默认)。 参数Type,指定要排序的元素。仅用于...
Range("a1:a10").Sort Order:=xlAscEnding ,Key1:=Range("a1")可以把order理解为动词排序,xlascending理解为副词升序,“:=”就是动词和副词的连接符。
1. 带参数名引用,如: key1:=Range("G3") 带参数名引用时 2. 参数位置引用,即按照上述Sort命令的参数顺序直接应用, 如: Range("A1:I19").Sort key1:=Range("G3") 即第1位置参数即为key1 ② Order1、Order2、Order3 这些Order是排序的顺序模式指定参数。即: A-Z升序、或Z-A降序 ...
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, SortMethod _:=xlPinYin Range("B2").Select '第二次排序,按基准D1,A1,B1 来实现 Selection.Sort Key1:=Range("D1"), Order1:=xlAscending, Key2:=Range("A1") _, Order2:=xlAscending, Key3:=Range("B1"), Order3:=...
Range("A1:C" & Myrows).Sort Key1:=Range("a1"), Order1:=xlAscending, Key2:=Range( _"b1"), Order2:=xlAscending, Key3:=Range("c1"), Order3:=xlDescending, _Header:=xlYes 第一排序是Range("a1"),是升序,第二排序条件是Range("b1"),也是升序,第三排序条件是Range("c1"),是降序,上述...
Range("A1:G15").Sort Key1:=Columns("A"), order1:=xlAscending, Header:=xlYes 得到顺序为: 曹操(cao)在第一位,诸葛亮(zhu)在最后一位。 我们也可以使用SortMethod参数把中文排序方式改为按笔画数排列,如: Range("A1:G15").Sort Key1:=Columns("A"), order1:=xlAscending, Header:=xlYes, Sort...
在日常VBA中,自带的sort函数可以定义三个排序字段(key值) 举例代码如下: 1 2 3 4 5 6 7 8 9 10 11 Sub test() With Worksheets("SUMMARY OF DEPOT INVENTORY").Range("c10:o245") .Sort key2:=Worksheets("SUMMARY OF DEPOT INVENTORY").Range("d10"), _ key3:=Worksheets("SUMMARY OF DEPOT ...