Alternate Line Shading Excel How To Guide
In this article
Alternate line shading in Excel creates a visual band between rows which makes large data sets easier to scan and reduces errors when reading across columns.
What You'll Need
- A workbook with at least one worksheet that contains tabular data
- Microsoft Excel 2010 or later (the steps are the same in Excel 365 and Excel 2021)
- Permission to edit the sheet (the default for personal files)
If you are working with a printed table that you have scanned into Excel, make sure the data is entered as values and not as an image.
Step-by-Step
- Identify the exact block of cells that hold the data you want to shade. For example, if your table starts at cell A2 and ends at D50, select that range by dragging from A2 to D50.
- Open the Home tab on the ribbon and locate the Conditional Formatting button in the Styles group.
- Click Conditional Formatting and then choose New Rule from the dropdown list.
- In the New Formatting Rule dialog, select "Use a formula to determine which cells to format" at the bottom.
- In the formula box, type =MOD(ROW(),2)=0. This formula evaluates to TRUE for every even‑numbered row, which is the typical pattern for shading.
- Click the Format button to open the Format Cells window.
- Switch to the Fill tab and choose a light background colour such as "Light Grey 25%" or "Blue 10%". Avoid dark colours because they reduce readability.
- Confirm by clicking OK, then click OK again in the New Formatting Rule window to apply the rule.
- Check the result by scrolling through the selected range; every second row should now have the chosen fill colour.
If you prefer to shade odd rows instead, replace the formula with =MOD(ROW(),2)=1. The rest of the steps remain identical.
Advanced Formatting Options
Excel allows you to combine line shading with other visual cues. For instance, you can add a thin border around each row to further separate data.
- After applying the original shading rule, open the Conditional Formatting Rules Manager (Home > Conditional Formatting > Manage Rules).
- Select the shading rule and click Edit Rule.
- In the Edit Formatting Rule window, click the Format button again.
- Switch to the Border tab and choose a thin outer border style.
- Confirm with OK, then OK again to save.
This creates a subtle grid that is especially helpful when printing the sheet on a laser printer that does not reproduce background colours well.
Applying the Rule to Tables Dynamically
When you add new rows to a data table, the shading rule should automatically extend if the rule was applied to a structured table.
- Convert your range to an Excel Table by selecting any cell inside the range and pressing Ctrl T.
- In the Create Table dialog, ensure the range is correct and check "My table has headers" if applicable.
- With the table selected, go back to Conditional Formatting and repeat steps 3 through 7 of the basic process.
- The formula will now be applied to the entire table, and any new rows added at the bottom will inherit the shading pattern.
If the shading does not appear on new rows, verify that the table’s name is included in the "Applies to" range of the rule. You can edit this range in the Rules Manager.
Common Mistakes and How to Fix Them
One frequent error is selecting the entire worksheet before creating the rule. When the entire sheet is selected, the rule applies to every cell, including empty ones, which can cause unwanted shading in header rows or footer areas.
Another mistake is typing the formula incorrectly. The MOD function must be written exactly as =MOD(ROW(),2)=0; extra spaces or missing parentheses will cause the rule to evaluate as FALSE for all rows.
If shading appears on the wrong rows, double‑check the formula. Using =MOD(ROW(),2)=1 will shade odd rows, while =MOD(ROW(),2)=0 shades even rows. A typo such as =MOD(ROW(),2)= will produce an error and the rule will not fire.
Sometimes the rule seems to work but the colour is too dark. Choose a lighter shade from the palette or customize the colour using the More Colors option to set a specific RGB value, such as RGB(242,242,242) for a very light grey.
Tips for Consistent Appearance
When the worksheet contains multiple tables, it is best to apply shading to each table separately. This prevents a single rule from affecting cells outside the intended area.
- Select the first table’s data range and create the shading rule as described.
- Repeat the process for the second table, using a different fill colour if you want visual distinction.
If you need to copy the shading to another sheet, you can copy the entire rule: open the Rules Manager on the source sheet, select the rule, click Copy, then switch to the target sheet, open the Rules Manager, and paste the rule. Adjust the "Applies to" range if the new sheet uses different cell references.
Remember to update the rule after deleting rows. Deleting rows does not automatically renumber the remaining rows, so the MOD formula still refers to the original row numbers. To keep shading consistent, re‑apply the rule after major structural changes.
Troubleshooting
If the shading does not appear after following the steps, perform these checks in order:
- Confirm that the rule is enabled. In the Rules Manager, the checkbox next to the rule should be ticked.
- Verify the "Applies to" range includes the cells you selected. It should look something like =$A$2:$D$50.
- Check that the formula is exactly =MOD(ROW(),2)=0 or =MOD(ROW(),2)=1 depending on the desired pattern.
- Make sure the workbook is not in Page Layout view with "Print" settings that hide background colours. Switch to Normal view to see the shading.
- If the rule still does not work, delete the rule and recreate it from scratch; sometimes corrupted rule data prevents proper execution.
When troubleshooting, start with the simplest checks (rule enabled, correct range) before moving to more involved fixes.
Frequently Asked Questions
Can I change the shading colour after the rule is applied?
Yes. Open the Rules Manager, edit the rule, and choose a new fill colour in the Format dialog.
Will the shading print on a black‑and‑white printer?
Background colours are not printed unless you enable "Print background colours and styles" in the Page Layout Options.
Is there a shortcut to open Conditional Formatting without using the mouse?
Press Alt H L to open the Conditional Formatting menu quickly.
Can I apply different shading to every third row?
Use a formula such as =MOD(ROW(),3)=0 to shade rows that are multiples of three, or =MOD(ROW(),3)=1 for a different pattern.
Does the rule work in Excel for Mac?
Yes, the steps are identical; the only difference is the location of the Conditional Formatting button on the ribbon.
Will shading affect formulas that reference row numbers?
No. Shading is purely a visual attribute and does not alter the underlying cell values or formulas.
Can I use a custom font colour instead of a fill colour?
Conditional Formatting can also change font colour; however, line shading typically uses a fill colour to create a background band.
Additional Practical Example
Imagine you have a sales report with columns for Date, Product, Quantity, and Revenue. The data starts at row 2 and extends to row 101. After applying the even‑row shading rule, every second row will have a light grey background. This makes it easy to follow a single product’s line across columns without losing track of which row you are reading.
To test the effect, scroll down the sheet and pause at a shaded row; the light colour should be subtle enough that the text remains crisp while still providing a visual break. If the shading feels too pronounced, return to the Format dialog and select a lighter shade or adjust the transparency slider if available.
Now add a new row at the bottom for a newly launched product. Because the rule was applied to a table, the new row automatically inherits the shading pattern. Verify that the new row is shaded correctly by checking the colour; if it is not, revisit the Rules Manager and ensure the "Applies to" range includes the new row.
Finally, prepare the sheet for printing. Open the Page Layout view, click Print Titles, and under the Sheet Options section, check "Print" under Gridlines if you want the borders to appear. Then, if you want the background colours to appear on paper, go to Page Setup, choose Sheet, and enable "Print" under "Print Background Colors and Styles". This ensures that the shaded rows are visible on the printed copy, which can be useful for sharing reports with stakeholders who prefer a hard copy.