Page 226 - Excel Workbook for Dummies
P. 226

23_798452 ch16.qxp  3/13/06  7:40 PM  Page 209
                                                                      Chapter 16: Building and Maintaining Data Lists  209


                                         Be sure to clear all but the Sort By key in the Sort dialog box.
                                         Be sure to select its Descending option button after selecting Date Hired as the
                                         Sort By key.
                                     5. Sort the Employee Data List so that its records are in order from the highest to
                                         the lowest salary.
                                     6. Close the Solved16-2.xls workbook file without saving your changes.



                                    Sorting on more than three keys

                                    Sometimes, you may need to sort on more three fields (the maximum you can define in
                                    one sorting operation). For example, suppose you are working with a personnel data list
                                    and you want to organize the records in alphabetical order by first by department, and
                                    then by supervisor, and finally by last name, first name, and middle name. To sort the
                                    records in this data list by these five fields, you have to perform two sorting operations:

                                        For the first sort, define the Last Name field as the primary key, the First Name
                                         field as the secondary key, and the Middle Name field as the third key
                                        For the second sort, define the Department field as the primary key and the
                                         Supervisor field as the secondary key

                          Try It

                                    Exercise 16-4: Sorting the Records in a Data List on More Than Three Keys

                                    Open the Exercise16-4.xls file in your Chapter 16 folder in the My Practice Spreadsheets
                                    folder on your hard disk or in the Excel Workbook folder on the workbook CD-ROM.
                                    This workbook contains a copy of the Personnel Data List that you will sort in alpha-
                                    betical order by first by the department name, and then by the supervisor’s name,
                                    and finally by the employee’s last, first, and middle name:

                                     1. Choose Data➪Sort to open the Sort dialog box and then select the Sort By and
                                         Then By keys to sort the Personnel Data List in alphabetical order by last, first,
                                         and middle name before you select OK.
                                         Check the Last Name, First Name, and Middle Name fields in the sorted data list
                                         and verify that they are now all in alphabetical order by last, first, and middle
                                         name.

                                     2. Sort the Personnel Data List a second time, this time in alphabetical order by
                                         department and then by supervisor.
                                         Check the Department and Supervisor fields in the re-sorted data list and verify
                                         that they are now in alphabetical order first by department name and then by
                                         supervisor name. Note in the case of supervisor Jones in the Sales department
                                         that the name of her employees are in order by last name and then first name.
                                     3. Save your sorted Personnel Data List worksheet in a new workbook file named
                                         Solved16-4.xls in your Chapter 16 folder in the My Practice Spreadsheets folder
                                         and leave the workbook file open for the next exercise.


                                    Sorting the fields (columns) in a data list

                                    You can use Excel’s column sorting capability to change the order of the fields in a
                                    data list without having to resort to cutting and pasting various columns. To sort the
                                    fields in a data list, add a row at the top of the list containing numbers from 1 to the
   221   222   223   224   225   226   227   228   229   230   231