SOLVED

Conditional formatting to change row color when cell value changes

%3CLINGO-SUB%20id%3D%22lingo-sub-3038654%22%20slang%3D%22en-US%22%3EConditional%20formatting%20to%20change%20row%20color%20when%20cell%20value%20changes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3038654%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20use%20conditional%20formatting%20to%20shade%20%22groups%22%20of%20rows%20when%20the%20value%20in%20column%20A%20changes%20(so%20all%20rows%20with%20the%20same%20value%20are%20either%20shaded%20or%20not).%26nbsp%3B%20To%20distinguish%20when%20the%20key%20value%20changes%2C%20I%20added%20a%20new%20column%20(N)%20and%20set%20the%20value%20of%20row%201%20to%20be%20%3CEM%3E%3DTRUE()%3C%2FEM%3E.%26nbsp%3B%20Then%20for%20rows%202%20thru%20the%20end%2C%20I%20added%20the%20formula%26nbsp%3B%3CEM%3E%3DIF(A2%3DA1%2CN1%2CNOT(N1))%3C%2FEM%3E%3B%20so%20effectively%20the%20value%20of%20the%20cell%20in%20N%20alternates%20from%20TRUE%20to%20FALSE%20when%20the%20value%20in%20A%20changes.%26nbsp%3B%20This%20part%20seems%20to%20work%20as%20intended.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20I%20created%20a%20conditional%20formatting%20rule%20where%20it%20adds%20a%20fill%20color%20to%20the%20row%20based%20on%20the%20formula%26nbsp%3B%3CEM%3E%3DAND(LEN(%24A2)%26gt%3B0%2C%24N2)%3C%2FEM%3E%3B%20so%20there%20has%20to%20be%20a%20value%20in%20column%20A%20and%20the%20value%20in%20column%20N%20must%20be%20TRUE.%26nbsp%3B%20It%20is%20shading%20some%20rows%20and%20not%20others%2C%20but%20not%20as%20expected%3B%20see%20photo%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Untitled.png%22%20style%3D%22width%3A%20106px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F333849iED9D95699DF1B523%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Untitled.png%22%20alt%3D%22Untitled.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EThe%20top%20row%20is%20A%20with%20%3DTRUE()%20in%20it%2C%20and%20the%20subsequent%20rows%20with%20the%20formula%20are%20correctly%20alternating%20between%20TRUE%20and%20FALSE%20when%20the%20key%20value%20in%20A%20is%20changing%20(effectively%20when%20the%20group%20changes).%26nbsp%3B%20But%20I%20can't%20figure%20out%20what%20the%20conditional%20formatting%20is%20doing.%26nbsp%3B%20I%20assume%20I've%20missed%20something%20but%20can't%20see%20it%2C%20so%20any%20thoughts%20are%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBTW%2C%20this%20is%20Excel%20for%20Mac%20v16.57.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3038654%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3038719%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20to%20change%20row%20color%20when%20cell%20value%20changes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3038719%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3BIt%20looks%20like%20the%20selection%20was%20off%20...%20I%20was%20trying%20to%20apply%20it%20to%20all%20the%20rows%20in%20the%20target%20columns%20(i.e.%2C%20%24A%3A%24N)%2C%20but%20redoing%20it%20with%20the%20specific%20cells%20seemed%20to%20fix%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3038659%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20formatting%20to%20change%20row%20color%20when%20cell%20value%20changes%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3038659%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1251309%22%20target%3D%22_blank%22%3E%40shawnc1959%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20looks%20like%20the%20rule%20is%20one%20row%20off.%3C%2FP%3E%0A%3CP%3EDelete%20the%20rule%20and%20start%20over.%3C%2FP%3E%0A%3CP%3EMake%20sure%20that%20the%20active%20cell%20in%20the%20selection%20is%20in%20the%20first%20row%20of%20the%20selection.%3C%2FP%3E%0A%3CP%3EAlso%20make%20sure%20that%20the%20formula%20in%20the%20rule%20refers%20to%20the%20cell%20in%20that%20row%20in%20column%20N.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I'm trying to use conditional formatting to shade "groups" of rows when the value in column A changes (so all rows with the same value are either shaded or not).  To distinguish when the key value changes, I added a new column (N) and set the value of row 1 to be =TRUE().  Then for rows 2 thru the end, I added the formula =IF(A2=A1,N1,NOT(N1)); so effectively the value of the cell in N alternates from TRUE to FALSE when the value in A changes.  This part seems to work as intended.

 

Then I created a conditional formatting rule where it adds a fill color to the row based on the formula =AND(LEN($A2)>0,$N2); so there has to be a value in column A and the value in column N must be TRUE.  It is shading some rows and not others, but not as expected; see photo:

Untitled.png

The top row is A with =TRUE() in it, and the subsequent rows with the formula are correctly alternating between TRUE and FALSE when the key value in A is changing (effectively when the group changes).  But I can't figure out what the conditional formatting is doing.  I assume I've missed something but can't see it, so any thoughts are appreciated.

 

BTW, this is Excel for Mac v16.57.

2 Replies
best response confirmed by shawnc1959 (New Contributor)
Solution

@shawnc1959 

It looks like the rule is one row off.

Delete the rule and start over.

Make sure that the active cell in the selection is in the first row of the selection.

Also make sure that the formula in the rule refers to the cell in that row in column N.

@Hans Vogelaar It looks like the selection was off ... I was trying to apply it to all the rows in the target columns (i.e., $A:$N), but redoing it with the specific cells seemed to fix it.

 

Thanks!