Google-sheets – way to stripe rows based on change of date in Google Spreadsheets

google sheets

I would like to not zebra stripe a spreadsheet in Google but to have the sections change color and alternate between dates. So 7/1/2015, even if there are 5 rows dated this would be color A, 7/2/2015 would all be color B, then 7/3/2015 would all be color A … and so on. Is there a formula for this to use in conditional formatting?

Best Answer

If you never skip a date, an easy approach is to color based on custom formula =ISODD($A2) (assuming the date is in column A), applying this formula to the range such as A2:Z100. The reason this works is that the date is in fact just the number of days since the last day of 1899. This value being even or odd alternates between days. The command =ISEVEN($A2) can be used for the other color.

If you do skip a date sometimes, the formula has to be a bit more complicated (and slower):

=ISODD(COUNT(UNIQUE($A$1:$A2)))

This counts the number of unique numerical values (which the dates are) in column A at or above the current cell. The color is applied based on the number being even or odd.