bottom
Great ExcelTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > ExcelTips Home > Formatting > Borders and Shading > Automatic Lines for Dividing Lists

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.

Tip #3189 applies to Microsoft Excel versions: 97 | 2000 | 2002 | 2003 | 2007


PivotTables Got You Perplexed? ExcelTips: PivotTables for the Faint of Heart shows how you can start using Excel's PivotTable tool right away to spin your data into gold! You discover how easy it really is to crunch the numbers you need to crunch. Uncover the power of the PivotTable Wizard, how to edit PivotTables, how to format them, how to customize them, and much more.
 
Check out ExcelTips: PivotTables for the Faint of Heart today!

Helpful Links

Ask an Excel Question
Make a Comment

Tips.Net Home
Vital News Home

ExcelTips FAQ
ExcelTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
ExcelTips Site

 

Great Info!

Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)