Sort two columns Excel [closed]

若如初见. 提交于 2019-12-12 01:08:48

问题


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"


回答1:


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. :-)



来源:https://stackoverflow.com/questions/11570650/sort-two-columns-excel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!