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.
Written by Allen Wyatt (last updated September 4, 2021)
This tip applies to Excel 97, 2000, 2002, and 2003
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.
Note:
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.
Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!
The Subtotals option on the Data menu is normally available for adding or removing subtotals to data tables. If the ...
Discover MoreIf you have a worksheet that has nested subtotals, you may have run across a problem where the subtotals and grand total ...
Discover MoreWhen you add subtotals to a worksheet, Excel typically places them in the same column that you are subtotaling. If you ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments