Reverse table using Excel SORTBY function

You are currently viewing Reverse table using Excel SORTBY function

Here, we will learn how to use the Excel dynamic array function: SORTBY. Later, we will also learn how to reverse the table using SORTBY and the COLUMN function, that returns the column number for the reference.

SORTBY function

The Excel SORTBY function sorts the values of a range based on the values from another range.

SORTBY takes three arguments: array, by_array and sort_order. The first required argument array, will take the range which is to be sorted. The second required argument by_array, will take the values to be used for sorting. The third optional argument sort_order determines the sort direction. 1 will sort in ascending order and -1 will sort in descending order. By default, the function will sort in ascending order.

Reversing table using SORTBY and COLUMN

To reverse the table, use the SORTBY formula and nest the COLUMN function in the by_array argument. The formula in F2 is:

=SORTBY(A2:D10,1-COLUMN(A2:D10))

As soon as I press Enter, the formula spills the results into the multiple cells automatically in the range F2:I10.

How this formula works

Since COLUMN is given the range A2:D10, it returns the column numbers in an array, like: {1,2,3,4}. Each number in the array is subtracted from 1 and now the array becomes like: {0,-1,-2,-3}. Negative numbers in the array force the SORTBY formula to reverse the range A2:D10.

You have successfully learnt how to use the Excel dynamic array function: SORTBY, and how to reverse the table! I hope this post helped you.

Download Practice Workbook

Kunal

Hey, I am Kunal Aggarwal, the founder and author of Kunal Excel Tip based in New Delhi, India. I have completed my postgraduation from NIIT Limited, New Delhi in Excel course in 2019. Since then, I have been using and learning Microsoft Excel and started writing posts on the spreadsheet software here since March 2024.

Leave a Reply