I need to sort an excel table into some other range using formula, like this:
Oritinal table:
A B C D
1 name val1 val2 val3 name val1 val2 val3
2 NN 5.70 0.50 1.20 LD 2.30 0.90 2.40
3 LD 2.30 0.90 2.40 sort by val1=> PL 4.60 0.80 3.30
4 PL 4.60 0.80 3.30 NN 5.70 0.50 1.20
step1: Using array formula {=INDEX($A$2:$D$4,MATCH(SMALL($B$2:$B$4,ROW()-ROW(A$7)+1),$B$2:$B$4,0),0)}, I get the following result:
7 LD LD LD LD
8 PL PL PL PL
9 NN NN NN NN
step2: Then I tested the index formula as {=INDEX($A$2:$D$4,2,0)}, here I specified a static row number, the index function returned a full row as expected:
7 LD 2.3 0.9 2.4
8 LD 2.3 0.9 2.4
9 LD 2.3 0.9 2.4
step3: Then another test with dynamic row numbers as {=INDEX($A$2:$D$4,ROW() - 6,0)}, now the function only return the first column as step1:
7 NN NN NN NN
8 LD LD LD LD
9 PL PL PL PL
Why index() returns just the first column with dynamic row numbers?
How can I sort the table with just formula (no vba, no GUI operation)?
=INDEX($A$2:$D$4;MATCH(SMALL($B$2:$B$4;ROW()-ROW(D$7)+1);$B$2:$B$4;0);0)
as your formula. Copy your formula to you targeted range and you'll get the result you wanted. – ctumturk{=INDEX($A$2:$D$4;MATCH(SMALL($B$2:$B$4;ROW()-ROW(A$7)+1);$B$2:$B$4;0);COLUMN(A$7))}
it should be enough. – ctumturk