After you have sorted the rows in an Excel 2007 worksheet or entered the data so that it doesn't need to be sorted, you can have Excel 2007 calculate subtotals or totals for a portion of the data. In a worksheet with sales data for three different product categories, for example, you can sort the products by category, select all the cells that contain data, and then open the Subtotal dialog box. To open the Subtotal dialog box, display the Data tab and then, in the Outline group, click Subtotal.
In the Subtotal dialog box, you can choose the column on which to base your subtotals (such as every change of value in the Week column), the summary calculation you want to perform, and the column or columns with values to be summarized. In the worksheet in the preceding graphic, for example, you could also calculate subtotals for the number of units sold in each category. After you define your subtotals, they appear in your worksheet. As the graphic shows, when you add subtotals to a worksheet, Excel 2007 also defines groups based on the rows used to calculate a subtotal. The groupings form an outline of your worksheet based on the criteria you used to create the subtotals. In the preceding example, all the rows representing months in the year 2006 are in one group, rows representing months in 2007 are in another, and so on. The outline section at the left of your worksheet holds controls you can use to hide or display groups of rows in your worksheet. There are three types of controls in the outline section: Hide Detail buttons, Show Detail buttons, and level buttons.
The Hide Detail button beside a group can be clicked to hide the rows in that group. In the previous graphic, clicking the Hide Detail button next to row 27 would hide rows 15 through 26 but leave the row holding the subtotal for that group, row 27, visible. When you hide a group of rows, the button next to the group changes to a Show Detail button. Clicking a group's Show Detail button restores the rows in the group to the worksheet. The level buttons comprise the other set of buttons in the outline section of a worksheet with subtotals. Each button represents a level of organization in a worksheet; clicking a level button hides all levels of detail below that of the button you clicked. The following table identifies the three levels of organization shown in the preceding graphic.
Clicking the Level 2 button in the worksheet shown in the preceding illustration would hide the rows with data on each month's revenue but would leave the row that contains the grand total (Level 1) and all rows that contain the subtotal for each year (Level 2) visible in the worksheet.
If you like, you can add levels of detail to the outline that Excel 2007 creates. For instance, you might want to be able to hide revenues from January and February, which you know are traditionally strong months. To create a new outline group within an existing group, select the rows you want to group; on the Data tab, in the Outline group, point to Group and Outline, and then click Group. You can remove a group by selecting the rows in the group and clicking Ungroup from the Data tab Outline group. Tip If you want to remove all subtotals from a worksheet, open the Subtotal dialog box and click the Remove All button. In this exercise, you will add subtotals to a worksheet and then use the outline that appears to show and hide different groups of data in your worksheet.
USE the GroupByQuarter workbook in the practice file folder for this topic. This practice file is located in the My Documents\Microsoft Press\Excel SBS\Sorting folder. OPEN the GroupByQuarter workbook.
CLOSE the GroupByQuarter workbook. |