Excel.Tips.Net Welcome toExcel.Tips.Net

Helpful Links

Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment

Tips.Net Store

ExcelTips FAQ
ExcelTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

Newest Tips

Recording a Macro

Adding a Little Animation to Your Life

Converting a Range of URLs to Hyperlinks

Making the Formula Bar Persistent

Engineering Calculations

Digital Signatures for Macros

Fixing the Decimal Point

 

Automatic Lines for Dividing Lists

Summary: You can use conditional formatting to add automatic dividing lines between groups of data in your worksheets. This tip shows how easy it is to add the lines. (This tip works with Microsoft Excel 97, Excel 2000, Excel 2002, Excel 2003, and Excel 2007.)

Let's say you have a list of company transactions. Each transaction includes a department number, a title, and other information (amount, date, time, sales rep, etc.). As you get more and more of these items in your list, you may want a way to automatically add "dividing lines" based on the department number. For instance, when the department number changes, you may want to include a line between the two departments.

To add this type of formatting to your list, start by sorting your data table by department. Then follow these steps:

  1. Select the left-most cell of the first row of your data. For instance, if your table heads are in row 3 (columns A through J), and your first row of data is in row 4, you should select cell A5.
  2. Press Shift+Ctrl+End. All the cells in your data table should be selected, with the exception of the header row.
  3. Choose Conditional Formatting from the Format menu. Excel displays the Conditional Formatting dialog box.
  4. Make sure the first drop-down list is "Formula Is." (Click here to see a related figure.)
  5. In the formula area, enter "=$A4<>$A5" (without the quote marks).
  6. Click the Format button. Excel displays the Format Cells dialog box.
  7. Display the Border tab. (Click here to see a related figure.)
  8. Click the None button to remove any borders already applied to the cells.
  9. In the Style list, select the type of border you want to appear between departments.
  10. In the Border area of the dialog box, click the button that adds your selected border style to the bottom of the cells.
  11. Click OK to close the Format Cells dialog box.
  12. Click OK to close the Conditional Formatting dialog box.

The steps for adding the proper conditional formatting are a bit different in Excel 2007. (The formula you use is the same; it is just the steps that are different.) Follow these, after you've sorted your list by department:

  1. Select the left-most cell of the first row of your data. For instance, if your table heads are in row 3 (columns A through J), and your first row of data is in row 4, you should select cell A5.
  2. Press Shift+Ctrl+End. All the cells in your data table should be selected, with the exception of the header row.
  3. With the Home tab of the ruler displayed, click the Conditional Formatting option in the Styles group. Excel displays a palette of options related to conditional formatting.
  4. Choose Highlight Cells Rules and then choose More Rules from the resulting submenu. Excel displays the New Formatting Rule dialog box.
  5. In the Select a Rule Type area at the top of the dialog box (Click here to see a related figure.) , choose Use a Formula to Determine Which Cells to Format.
  6. In the Format Values Where This Formula Is True box, enter "=$A4<>$A5" (without the quote marks).
  7. Click Format to display the Format Cells dialog box.
  8. Display the Border tab.
  9. Click the None button to remove any borders already applied to the cells.
  10. In the Style list, select the type of border you want to appear between departments.
  11. In the Border area of the dialog box, click the button that adds your selected border style to the bottom of the cells.
  12. Click OK to dismiss the Format Cells dialog box. The formatting you specified in steps 10 and 11 should now appear in the preview area for the rule.
  13. Click OK.

That's it; you should now see a line that appears across the entire width of your data every time the department changes.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (3189) applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007

Change Formatting Based On Your Data! Conditional formatting provides a way for you to adjust the appearance of your data based on the data itself. Discover how to put this amazingly powerful feature to work for you, today. This comprehensive volume is available in two editions.
 
Check out Excel Conditional Formatting today!