How to Shade Alternate Rows in Excel?
We can shade every alternate row in excel by using the conditional formatting technique, and we can do this by following multiple methods.
Below is the data I am going to use. You can download the workbook to practice along with me.
Method #1 – Without Using Helper Column
The first method we are going to use is conditional formatting without using the helper column. Follow the below steps to shade every alternate row in excel.
- Step 1: Select the entire data (without heading).
- Step 2: Go to Conditional Formatting and choose “New Rule.”
- Step 3: In the next window, choose “Use a formula to determine which cells to format.”
- Step 4: In the conditional formatting formula, the bar enters the below formula.
- Step 5: Now, click on the Format tab to choose the formatting color.
- Step 6: Now, it will open up the format cells window. From this window, choose the tab “FILL” and choose the color as per your wish.
- Step 7: Now click on Ok to see the shades in an alternative row.
If you are wondering how this has been done, then say thanks to the formula we have put in, i.e., =MOD(ROW(),2)=1
4.9 (1,353 ratings) 35+ Courses | 120+ Hours | Full Lifetime Access | Certificate of Completion
MOD is the formula to be used to get the remainder value when we divide one number by the other number. 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() function will return the respective row number, and the same row number will be divided by number 2, and if the remainder is equal to number 1, then that row will be highlighted or shaded by the color we have chosen.
Method #2 – Using Helper Column
By simply inserting the helper column of serial numbers, we can shade alternate rows in excel.
- For this first insert 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 this time, we need to change only the formula. Insert the below formula.
- Click on OK. We will get an alternative shaded row.
If you look at the previous one and this one, it is slightly different. In the previous one from the second row of the data was shaded, but in this one, starting from the first row of the data, itself row has been highlighted.
Method #3 – Using VBA Coding
You can simply use the below VBA code to shade every alternative row. Use the below code to shade alternate rows in excel.
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
- Not only alternative rows, but you can also shade every 3rd row, 4th row or 5th row, and so on. For that, you need to change the divisor value in the MOD function from 2 to 3.
- Conditional formatting works on the basis of logical results, TRUE or FALSE.
- ISODD and ISEVEN functions are useful with the helper column of serial numbers.
This has been a guide to Shade Alternate Rows in Excel. Here we discuss the top 3 methods to shade alternate rows in excel along with examples and a downloadable template. You may learn more about excel from the following articles –