You are here:

Excel/Alternate record shading based on column value changes

Advertisement


Question
QUESTION: I can't seem to find this question/answer and this is my first visit so will ask it:

I want to shade the records of a worksheet (Claims & Dollars) alternating between No fill and filled (The color isn't important.) based on a given column's contents on that same record.  The first record (header) is frozen.  The Autofilter function is on.  Example:  Say I'm using Column A values to trigger the alternate shading.  A2=100,  A3=100, A4=101, A5=102.  Records 2 & 3 would be shaded, record 4 wouldn't and record 5 would, et cetera.  It doesn't matter whether the first record begins with shaded or No fill, to me.

ANSWER: If it weren't a filtered list, it'd be pretty straightforward, but since it's filtered, and you may have A2=100 rows 3:6 filtered, A7=100, A8=101, A9=101, rows 10:30 filtered, A31=400, you'd need rows 2 & 8 to be shaded, 8 &9 not shaded, 31 shaded. This is not at all trivial and would require vba code, not conditional formatting. It would take a fair amount of time to come up with something that'd work. Sorry

---------- FOLLOW-UP ----------

QUESTION: So, nix the filtered aspect.  That make it easy enough?

Answer
You need a helper column. Say you have col H available. Enter this in H2:
=IF(A2=A1,IF(H1=1,1,0),IF(H1=1,0,1))
fill down as far as necessary (same # of entries as in A)
Select everything, use conditional formatting, change "cell value is" to "formula is", enter this formula:
=$H1=1, click the Format button, pick a color.
You can hide column H

HTH
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

All Answers

Answers by Expert:


Ask Experts

Volunteer


Bob Umlas

Expertise

I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...)

Experience

Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Publications
Excellence, The Expert, Microsoft

Awards and Honors
MVP
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

©2009 About.com, a part of The New York Times Company. All rights reserved.