Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to apply conditional formatting to change the background color of alternating rows on a spread sheet. The rows will alternate between two colors (yellow and green) two lines each.

This is the code I am using:

=MOD(ROW(),2)*($A1<>"")

and

=(1-MOD(ROW(),2))*($A1<>"")

It changes every other line, but I want every two lines to be the same color. What do I need to change to make that work?

share|improve this question
add comment

2 Answers

to save some processor cycles, you can format whole range with the 1st color and use this formula to conditionally format 3rd and 4th row of every 4 rows:

=MOD(ROW()-1;4)>1

if you use this conditional format only to used range, e.g. by creating an Excel Table (the one without alternating row colors), there should not be need to include $A1<>"", but feel free to use it anyway

share|improve this answer
add comment

Try this (matches rows 1, 2, 5, 6, etc):

=MOD(FLOOR(ROW()/2+0.5,1),2)*($A1<>"")

and this (matches rows 3, 4, 7, 8, etc):

=MOD(FLOOR(ROW()/2-0.5,1),2)*($A1<>"")
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.