I have a table with two columns which, by design, I know have the same values (here, colA
and colB
) but not in the same order. One of those is in the order I want (here, colA
). I want to order my whole table, except this column (colA
), so that another column (here, colB
) is in the order of the column in the right order (colA
).
Example:
colA colB colC
5 3 is
7 5 hello
3 7 this
4 4 dog
Desired result:
colA colB colC
5 5 hello
7 7 this
3 3 is
4 4 dog
(Notice that the values in colC
(and other columns) follow those in colB
) (each value in colA
and colB
is unique). Doing this in google sheets.
CodePudding user response:
try:
=INDEX(IFNA(VLOOKUP(A1:A4, B1:C4, {1, 2}, 0)))
or see: https://webapps.stackexchange.com/a/126631/186471
CodePudding user response:
Insert another column before A and give them a index starting at 1... 1,2,3,4... This will be used to do a final sort... Now all the columns are named differently then your example so take that into account when reading the below...
colA colB colC colD
1 5 3 is
2 7 5 hello
3 3 7 this
4 4 4 dog
Next sort colC and colD (and any other cols) in order of colC. Sort colA and colB in order of colB. Now the numbers in colB and ColC should match. Finally sort all by colA. Delete colA