我想使用另一列(位于另一个工作表中)中的值对工作表中的列进行排序。
例如,列中的值为" abc"," def"和" ghi"。这些值位于第一张纸的列中,但列的值混乱。我希望它们排序,使得值的大小为" abc"," def"和" ghi"。
我试过这个例子:
Sheets("Sheet1").Columns("G").Sort key1:=Sheets("Sheet2").Range("D:D"), order1:=xlAscending, Header:=xlYes.
我这样做时出错:
The sort reference is not valid. Make sure that it's within the data you want to sort, and the first Sort By box isn't the same or blank.
不确定错误是什么。需要一些帮助。
答案 0 :(得分:0)
您可以使用以下公式代替使用宏,并将记录排序。
=MATCH(A1,Sheet2!A:A,0)