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

Automatically Selecting Words

When editing a document, Word normally selects entire words as you use the mouse to select text. This tip explains why ...

Discover More

Pasting a Graphic to Multiple Worksheets

Do you need to add a logo or other graphic to a bunch of worksheets? Here are a couple of short macros that can make ...

Discover More

Adding Comments to Protected Worksheets

When you protect a worksheet, Excel stops users from editing or otherwise making changes to the data in the worksheet. If ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Drawing Borders

Adding borders around cells is a common formatting task. You can make the task more intuitive by actually drawing the ...

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

Rounded Corners on Cells

As you are formatting a worksheet, Excel allows you to easily add borders to cells. Adding rounded corners to cells is a ...

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 three minus 2?

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.