How to Shade Alternate Rows in Excel?

We can shade every alternate row in excel by using the conditional formatting techniqueConditional Formatting TechniqueConditional formatting is a technique in Excel that allows us to format cells in a worksheet based on certain conditions. It can be found in the styles section of the Home tab.read more. We can do this by following multiple methods.

Below is the data we are going to use. You can download the workbook to practice along here.

Method #1 – Without Using Helper Column

We will first use conditional formatting without the helper column.

If you are wondering how this has been done, then say thanks to the formula we have put in:

  • Select the entire data (without heading). Go to Conditional Formatting and choose “New Rule”. In the next window, choose “Use a formula to determine which cells to format”. In the conditional formatting formula, the bar enters the below formula. Click on the Format tab to choose the formatting color. Now, it will open up the format cells window. Choose the tab “FILL” and choose the color as per your wish. Click Ok to see the shades in an alternative row.

The MOD Excel function is the formula to get the remainder value when dividing one number by the other. For example, MOD (3, 2) will return 1 as the remainder, i.e., when we divide number 3 by number 2, we will get the remainder value as 1.

Similarly, the ROW() functionROW() FunctionThe row function in Excel is a worksheet function that displays the current row index number of the selected or target cell. The syntax to use this function is as follows: =ROW( Value ).read more will return the respective row number, and the same row number will be divided by number 2. Again, if the remainder equals number 1, that row will be highlighted or shaded by the chosen color.

Method #2 – Using Helper Column

We can shade alternate rows in Excel by inserting the helper column of serial numbers.

  • For this, we must first insert a “Serial Number” column like the below one.

  • Now select the data except the helper column.

  • Again, open “Conditional Formatting” and choose the same method, but we need to change only the formula this time. Insert the below formula.

  • Click on OK. We will get an alternative shaded row.

It is slightly different if you look at the previous and the current one. The previous one from the second row of the data was shaded. But in this one, starting from the first row of the data, the row itself has been highlighted.

Method #3 – Using VBA Coding

You can use the below VBA codeVBA CodeVBA code refers to a set of instructions written by the user in the Visual Basic Applications programming language on a Visual Basic Editor (VBE) to perform a specific task.read more to shade every alternative row. Use the below code to shade alternate rows in excel.

Code:

Sub Shade_Rows()

Dim Rng As Range Set Rng = Selection

Rng.FormatConditions.Add xlExpression, Formula1:="=MOD(ROW(),2)=1" Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority

With Selection.FormatConditions(1).Interior .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorAccent5 .TintAndShade = 0.399945066682943 End With

Selection.FormatConditions(1).StopIfTrue = False

End Sub

For this, first, you need to select the range of cells that needs to be shaded, then run the macro.

Things to Remember

  • We can also shade every third, fourth, or fifth row, alternative rows, and so on. We must change the divisor value in the MOD function from 2 to 3.The conditional formatting works based on logical results, “TRUE” or “FALSE.”The ISODD and ISEVEN functions are useful with the helper column of serial numbers.ISODD and ISEVEN functions are useful with the helper column of serial numbers.

This article is a guide to Shade Alternate Rows in Excel. Here, we discuss the top 3 methods to shade alternate rows in Excel, examples, and a downloadable template. You may learn more about Excel from the following articles: –

  • New Line in Excel CellExporting Excel Files into PDF Excel Box and Whisker PlotChange Font Color in VBA