Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.
With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company.
Learn more about Allen...
Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Formatting Subtotal Rows.
When you add subtotals to a worksheet, Excel automatically formats the subtotals using a bold font. You, however, may want to have some different type of formatting for the subtotals, such as shading them in yellow or a different color.
If you use subtotals sparingly and only want to apply a different format for one or two worksheets, you can follow these general steps:
Figure 1. The Go To dialog box.
Figure 2. The Go To Special dialog box.
If you will be repeatedly adding and removing subtotals to the same data table, you may be interested in using conditional formatting to apply the desired subtotal formatting. Follow these steps:
Figure 3. The Conditional Formatting dialog box.
Figure 4. The Format Cells dialog box.
When following the above steps, make sure that you replace A1 (steps 4 and 10) with the column in which your subtotals are added. Thus, if your subtotals are in column G, you would use G1 instead of A1.
If you need to do formatting of subtotals on quite a few worksheets, then you may want to create a macro that will do the formatting for you. The following macro examines all the cells in a selected range, and then applies cell coloring, as appropriate.
Sub FormatTotalRows() Dim rCell as Range For Each rCell In Selection If Right(rCell.Value, 5) = "Total" Then Rows(rCell.Row).Interior.ColorIndex = 36 End If If Right(rCell.Value, 11) = "Grand Total" Then Rows(rCell.Row).Interior.ColorIndex = 44 End If Next End Sub
The macro colors the subtotal rows yellow and the grand total row orange. The macro, although simple in nature, is not as efficient as it could be since every cell in the selected range is inspected. Nevertheless, on a 10 column 5000 row worksheet this macro runs in under 5 seconds.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2984) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Formatting Subtotal Rows.
Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!