## Highlight every other row

Here is how to highlight every other row using conditional formatting.

**Conditional formatting formula:**

**Alternative CF formula:**

This formula colors every second row if any cell in the row is populated. If you know you will add more records later to the list, select and conditional format a range larger than the list. Empty rows won´t be formatted.

**How to apply the conditional formatting formula in excel 2007:**

- Select the range, example cell range A:C
- Click "Home" tab on the ribbon
- Click "Conditional formatting"
- Click "New rule..."
- Click "Use a formula to determine which cells to format"
- Click "Format values where this formula is true" window.
- Type =ISEVEN(ROW())*OR($B3:$D3<>"")
- Click Format button
- Click "Fill" tab
- Select a color
- Click OK!
- Click OK!

### Explaining the contional formatting formula in cell A2

=ISEVEN(ROW())*OR($A2:$C2<>"")

**Step 1 - Check if row number is even**

=**ISEVEN(ROW())***OR($A2:$C2<>"")

ISEVEN(ROW())

becomes

ISEVEN(2)

returns TRUE in cell A2.

**Step 2 - Check if any of the cells in row are not empty**

=ISEVEN(ROW())***OR($A2:$C2<>"")**

OR($A2:$C2<>"")

becomes

OR({"Federer", " Roger ", 25}<>"")

becomes

OR({TRUE, TRUE, TRUE})

and returns TRUE

**Step 3 - Multiply functions (AND logic)**

Both functions need to return TRUE in order to return TRUE

=ISEVEN(ROW())*OR($A2:$C2<>"")

becomes

TRUE*TRUE

and returns TRUE. Row 2 is conditional formatted.

### Download excel sample file for this tutorial

color-every-second-row-using-dynamic-conditional-formatting.xls

(Excel 97-2003 Workbook *.xls)

**Functions used in this article**

**OR(**logical1, logical2, …**)**

Checks whether any of the arguments are TRUE and returns TRUE or FALSE. Returns FALSE only if all arguments are FALSE

**ROW(**reference**)**

Returns the row number of a reference

**ISEVEN(**number**)**

Returns TRUE if the number is even

Highlight overlapping date ranges using conditional formatting

The image above demonstrates a conditional formatting formula that colors a record if there is at least one record that […]

Highlight records based on overlapping date ranges and a condition

adam asks: Hi, I have a situation where I want to count if this value is duplicate and if it […]

Highlight dates in a date range

Question: How do I highlight dates that meet criteria using conditional formatting? Table of contents Highlight values in a column […]

The EVEN function rounds a number up to the nearest even whole number. An even number is a number that […]

Question: I have a list that I keep adding rows to. How do i create a border that expands as […]

How to filter using OR logic between columns [Formula]

The filter feature in Excel won't allow you to do OR logic between columns, however, you can if you allow […]

### 6 Responses to “Highlight every other row”

### Leave a Reply

### How to comment

**How to add a formula to your comment**

<code>Insert your formula here.</code>

**Convert less than and larger than signs**

Use html character entities instead of less than and larger than signs.

< becomes < and > becomes >

**How to add VBA code to your comment**

[vb 1="vbnet" language=","]

Put your VBA code here.

[/vb]

**How to add a picture to your comment:**

Upload picture to postimage.org or imgur

Paste image link to your comment.

**Contact Oscar**

You can contact me through this contact form

This is helpful, thanks, but I've been looking for the formatting to take place AS I fill new cells.

So my scenario is: A clear-formatted excel sheet, and ONCE you insert data into each row, the color of the row changes, e.g. row 1 becomes light blue, row 2 becomes dark blue, BUT row 3 is still clear-formatted because I haven't inserted data in it yet.

Do you know how I can do that?

*Thanks!!!*

@Sawsan,

Select all the cells (starting from upper left corner of the range so the the upper left cell ends up the active cell) that you think you will ever need to put your alternating row colors in (I would refrain from selecting entire columns), then follow the blog's instructions to get to the Conditional Formatting dialog box and then use this formula...

=AND(ISEVEN(ROW()),COUNTIF($A1:$C1,"*")>0)

Change the range as indicated, but note that your formula should only specify the first row's cells range even though you will have many more rows selected.

@Sawsan,

I guess I missed your request for a second color. That will require a second condition for the second color... use the identical formula I gave you in my previous message for this condition, but change the ISEVEN function to ISODD.

hi,

i'm interested to know on the conditional formatting.

how do i set the condition to evaluate a dynamic range?

my example is this:

Rule: =MAX($G$5:$G$20)=$G5

Applied to: =$AG$5:$AG$20

based on the value in G5:G20, the rule will determine the max value and highlight it on AG5:AG20

If i add new rows of data to G21 onwards, the rules does not "extend" to the newly added rows.

david,

I got this working in excel 2007:

Rule: =MAX(OFFSET($G$5;0;0;COUNTA($G5:$G1000))=$G5

Applied to: =OFFSET($AG$5;0;0;COUNTA($G5:$G1000)

thanks oscar,

i was using a dynamic named range as the rule in conditional formatting.

will try ur solutions ;)

thanks!!!