排列两列Excel [英] Sort two columns Excel
问题描述
我想创建一个脚本,它将对列F进行排序(有一个标题),并根据列F进行排序的方式对列B进行排序。 (不影响任何其他栏!)
所以如果我有
ColB ColF
1.猫2
2.鼠标1
3.狗3
排序将给我
ColB ColF
1.鼠标1
2.猫2
3.狗3
我该怎么做?
我尝试录制一个刚刚排序的宏,但是我收到一个错误,说无法使用多个选项执行命令,单击一个范围并重试
我可以想到的最简单的方法是将您的两列暂时复制到垂直查找表中,列左侧列F。
然后对列F进行排序,并使用以下格式更新列名为D的VLookup:
code> = VLOOKUP(F1,[Temp Table Range],2,FALSE)
然后如果要删除临时表,只需确保用列替换列D的公式。
您可以使用宏执行所有这些操作,只需几个步骤即可。我可以为你编写,但这并不是Stackoverflow的关键。
玩得开心: - )
I have two different columns on Excel. I want to create a script that will sort Column F, (Have a header) and will sort Column B based on where Column F's sort worked out. (Without affecting any other columns however!)
So if I have
ColB ColF
1. Cat 2
2. Mouse 1
3. Dog 3
The sort will give me
ColB ColF
1. Mouse 1
2. Cat 2
3. Dog 3
How can I do this? I tried recording a macro of just sorting it out, but I get an error saying "The command cannot be performed with multiple selections, Click a single range and try again"
The easiest way I can think of is to temporarily copy over your two columns into a vertical look-up table with column F on the left.
Then sort your column F and update column D with VLookup with the format like:
=VLOOKUP(F1,[Temp Table Range],2,FALSE)
Then if you want to delete the temp table, just make sure you replace column D's formulas with values.
You can do all of this with a macro it just has several steps. I could write it for you, but that isn't really what Stackoverflow is about.
Have fun. :-)
这篇关于排列两列Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!