Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Automatic Lines for Dividing Lists.
Written by Allen Wyatt (last updated December 29, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
Let's say you have a list of company transactions. Each transaction includes a department number, a title, and other information (amount, date, authorizer, 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. For the sake of this example, I'll assume that your data is actually in columns A:F, with the department numbers in column A. (See Figure 1.)
Figure 1. The data to be divided.
To add the automatic dividing lines, follow these steps:
Figure 2. The New Formatting Rule 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 (6863) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Automatic Lines for Dividing Lists.
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!
You can use conditional formatting to add shading to various cells in your worksheet. This tip shows how you can shade ...
Discover MoreSetting up conditional formatting can be challenging under some circumstances, but once set it can work great. Unless, of ...
Discover MoreConditional Formatting is a great boon to effectively displaying the information in your worksheets. If you want to ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2019-09-12 21:00:33
Artamov
This was a great tip! I found a macro to do the same, but it wouldn't underline the entire row. TIP: it's written down above, but is easy to miss: DO NOT SELECT THE HEADER ROW! Let's assume the header is Row 1. If you don't select the header row, your formula is "=$a2<>$a3. HOWEVER: If you do select the header row, then either change the "Applies to" in the rule to "=$2:$xxxxxxx", OR change the formula to "=$a1<>$a2".
2019-06-19 03:00:43
BBN,
Assuming your dates are in column A starting in A1 with a title, use the following formula in Conditional Formatting, applied to range A2:?? (to suit your data) & set whatever formatting you want.
=IFERROR(MONTH(A2)<>MONTH(A1),1)
This will find the beginning of the month, if you prefer the end of the month use the following formula applied to the same range
=(MONTH(A3)<>MONTH(A2)
The IFERROR in the first formula deals with the title in A1, it is not required in the second formula as there is no reference to A1.
All the usual warnings when applying Conditional Formatting, as to inserting rows or adding data to the end of the list. It is also possible to use VBA to apply formatting to a required range, but that might be a step too far at the moment.
HTH
Steve
2019-06-18 06:27:00
Richard
Geoff: One option is to apply the conditional formatting way beyond the end of your data. In Home > Conditional Formatting > Manage Rules, adjust the Applies To range to apply the formatting to some suitable row number depending on your data (say row 10,000), e.g. $A$2:$A$10000.
If this produces undesirable effects below your data, qualify the condition using an IF expression, e.g. IF (A2<>"", <your condition>).
2019-06-10 11:34:36
BBN
I used to work for a company that had several hundred clients, for each of which I'd have to perform an annual task on a day specific to that client. I did up a spreadsheet and just manually kept a solid black line between each of the months as I liked to see what was coming up as each month approached. Is there a variation on that formula that could be used on such a spreadsheet to separate the months? (Note: I know I *could* use conditional formatting to just use, example, shading, but two problems: one, I actually dislike shaded cells and find they make data *more* difficult for me to read rather than less. And two, we only had a very old b&w printer, and any spreadsheet using colored cells just looked like garbage when printed off.)
2019-06-08 06:03:40
Geoff Robb
I use this conditional formatting in a spreadsheet I have developed, but I often find that the formatting does not copy down prperly when adding data at the bottom of the table (ie adding rows at the bottom) . Is there a reliable way to have the formatting copied down automatically as new data is entered? I have tried copying the formatting down below the data, but the new rows appear to overwrite the conditional formatting.
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu 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