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: Automatic Lines for Dividing Lists.

Automatic Lines for Dividing Lists

Written by Allen Wyatt (last updated April 30, 2022)
This tip applies to Excel 97, 2000, 2002, and 2003


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 A4.
  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." (See Figure 1.)
  5. Figure 1. The Conditional Formatting dialog box.

  6. In the formula area, enter "=$A4<>$A5" (without the quote marks).
  7. Click the Format button. Excel displays the Format Cells dialog box.
  8. Display the Border tab. (See Figure 2.)
  9. Figure 2. The Borders tab of the Format Cells dialog box.

  10. Click the None button to remove any borders already applied to the cells.
  11. In the Style list, select the type of border you want to appear between departments.
  12. In the Border area of the dialog box, click the button that adds your selected border style to the bottom of the cells.
  13. Click OK to close the Format Cells dialog box.
  14. Click OK to close the Conditional Formatting dialog box.

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 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Automatic Lines for Dividing Lists.

Author Bio

Allen Wyatt

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. ...

MORE FROM ALLEN

Vertically Centering Labels

Want the text printed on your labels to be centered vertically? It's not that hard, and this tip shows the easiest method.

Discover More

Checking for a Value in a Cell

Need to figure out if a cell contains a number so that your formula makes sense? (Perhaps it would return an error if the ...

Discover More

Counting Records Matching Multiple Criteria

Excel provides worksheet functions that make it easy to count things. What if you want to count records that match more ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

More ExcelTips (menu)

Replacing Background Colors in Cells

Want a quick way to replace background colors in cells? It's easy to do using Find and Replace, or you can simply use the ...

Discover More

Removing Borders

Need to get rid of the borders around a cell? The shortcut in this tip can make quick work of this formatting task.

Discover More

Adding Borders to Cells

Excel makes it easy to add all sorts of lines around a cell or range of cells. How easy? This tip demonstrates how to add ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 8 - 5?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.