In Excel, there are a few ways you can sort a data set. You can:
- Click on Data/Sort then navigate the Sort Data dialog box.
- Right click on a highlighted a data set and hit sort.
- Apply a filter to a data set, then click on the filter arrows, and then select “Sort A to Z” or “Sort Z to A”.
It would be faster, however, to highlight all the rows of a data set and then have it sort on the active field.
To do that, you would have to do the following:
- First go to the cell you want to use as the sort key, in the top row of the data that you want to sort
- Then highlight that column by pressing Shift+End+DownArrow
- Then highlight the rows to sort by pressing Shift + Spacebar.
- Then run a macro to sort the rows based on the active field.
Running the macro multiple times should toggle between ascending and descending sort orders.
You can start by recording a macro that records your sorting of a data set, but you may run in to trouble with hardcoded references being placed in your code. Because of this, you will likely have to find another way to accomplish this task, so that the macro you record here can be useful in other spreadsheets.
Your assignment is to write this macro.