I want to reverse columns of spreadsheet. Sample is "p227", "s121", "p117", "p252", "s215" in column "A1:E1". Values are random. I want to reverse this column like "s215", "p252","p117", "s121", "p227".
I tried =TRANSPOSE(SORT(TRANSPOSE(A1:E1),1,false))
. But output is "s255", "s121", "p212", "p187", "p121"
. Values are sorted. This doesn't reverse columns. Is there way to solve this? Should I use GAS?
Sample
A B C D E
1 p227 s121 p117 p252 s215
Expected result
A B C D E
1 s215 p252 p117 s121 p227
Thank you so much for your time.
Try
=TRANSPOSE(SORT(TRANSPOSE(A1:E1),TRANSPOSE(COLUMN(A1:E1)),0))
Here's a general one
Method:
Transpose
Add row numbers
Sort descending by row number
Transpose
Remove row numbers
Formula:
=ArrayFormula(query(TRANSPOSE(sort({row(indirect("1:"&columns(A1:E2))),transpose(A1:E2)},1,false)),"select * offset 1"))
EDIT
On reflection this would have been a bit neater, adding column numbers before transposing and avoiding the Indirect:
=ArrayFormula(query(TRANSPOSE(sort(transpose({COLUMN(A1:E2);A1:E2}),1,false)),"select * offset 1"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With