SOLVED
Home

Conditional Formatting with multiple conditions

%3CLINGO-SUB%20id%3D%22lingo-sub-1018719%22%20slang%3D%22en-US%22%3EConditional%20Formatting%20with%20multiple%20conditions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1018719%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20the%20attached%20file%20I%20am%20trying%20to%20figure%20a%20way%20to%20do%20the%20following%20steps%2C%20in%20said%20order%3A%3C%2FP%3E%3COL%3E%3CLI%3EHighlight%20row%20every%2010th%20day%20(completed)%3C%2FLI%3E%3CLI%3ECompare%20Column%20C%20values%20for%20every%2010%20day%20range%20and%20highlight%20in%20red%20the%20%3CU%3E%3CSTRONG%3Ehighest%20value%3C%2FSTRONG%3E%3C%2FU%3E%20(partially%20completed%20but%20need%20to%20automate%20it%2C%20currently%20have%20copy%20pasted%20conditional%20formatting%20for%20every%2010%20day%20range)%3C%2FLI%3E%3CLI%3ECompare%20Column%20D%20value%20for%20every%2010%20day%20range%20and%20highlight%20in%20green%20the%20%3CSTRONG%3E%3CU%3Elowest%20value%3C%2FU%3E%3C%2FSTRONG%3E%26nbsp%3B(partially%20completed%20but%20need%20to%20automate%20it%2C%20currently%20have%20copy%20pasted%20conditional%20formatting%20for%20every%2010%20day%20range)%3C%2FLI%3E%3CLI%3EFrom%2010%20day%20range%20%3CSTRONG%3Elowest%20value%3C%2FSTRONG%3E%20need%20to%20highlight%20%3CU%3E%3CSTRONG%3E2%20highest%20value's%20(Column%20C)%20pre%20and%20post%26nbsp%3B%3C%2FSTRONG%3E%3C%2FU%3E%3CU%3E%3CSTRONG%3Elowest%20value%20date%3C%2FSTRONG%3E%3C%2FU%3E%20(need%20to%20figure%20this)%3C%2FLI%3E%3C%2FOL%3E%3CP%3ENOTE%3A%20New%20data%20will%20be%20added%20every%20day%20or%20week.%20Previous%2010%20day%20highlights%20should%20not%20be%20removed%20with%20new%2010%20day%20highlights%2C%20so%20if%20there%20is%206%20months%20of%20data%20there%20would%20be%20~18.25%2C%2010%20day%20ranges%2C%20therefore%20~18%20lowest%20value%20shown%20on%20the%20spreadsheet.%20Would%20prefer%20without%20Macro%20and%2For%20VBA%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1018719%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EBI%20%26amp%3B%20Data%20Analysis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20for%20web%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%20on%20mobile%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETraining%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1019084%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20with%20multiple%20conditions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1019084%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F462388%22%20target%3D%22_blank%22%3E%40Eklavya%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20for%202)%20and%203)%20you%20may%20apply%20rules%20with%20formulas%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3D(D2%3DAGGREGATE(15%2C6%2C1%2F((INT((ROW()-2)%2F10)%2B1)%3D(INT((ROW(%24D%242%3A%24D%241000)-2)%2F10)%2B1))*%24D%242%3A%24D%241000%2C1))*(D2%26lt%3B%26gt%3B0)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3Band%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3D(C2%3DAGGREGATE(14%2C6%2C1%2F((INT((ROW()-2)%2F10)%2B1)%3D(INT((ROW(%24D%242%3A%24D%241000)-2)%2F10)%2B1))*%24C%242%3A%24C%241000%2C1))*(C2%26lt%3B%26gt%3B%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EAs%20for%204)%20-%20have%20no%20solution%20so%20far%2C%20not%20for%20today...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1020128%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20with%20multiple%20conditions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1020128%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BThis%20is%20good.%20Consulted%20an%20excel%20expert%20chat%20(ExcelChat%20by%20Got%20It%2CInc)%2C%20they%20are%20generally%20good%20but%20for%20this%20they%20did%20not%20have%20any%20any%20solution%2C%20wasted%20good%205-6%20hours%20with%20them%20on%20this%20over%20an%20above%20trying%20to%20figure%20it%20out%20myself.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EReally%20appreciate%20this.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%204th%20one%20is%20a%20brain%20scratcher.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1020140%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20with%20multiple%20conditions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1020140%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3BIf%20you%20don't%20mind%2C%20can%20you%20walk%20me%20through%20the%20logic%20of%20the%20formulae%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3D(D2%3DAGGREGATE(15%2C6%2C1%2F((INT((ROW()-2)%2F10)%2B1)%3D(INT((ROW(%24D%242%3A%24D%241000)-2)%2F10)%2B1))*%24D%242%3A%24D%241000%2C1))*(D2%26lt%3B%26gt%3B0)%3C%2FPRE%3E%3CP%3E%26nbsp%3Band%3C%2FP%3E%3CPRE%3E%3D(C2%3DAGGREGATE(14%2C6%2C1%2F((INT((ROW()-2)%2F10)%2B1)%3D(INT((ROW(%24D%242%3A%24D%241000)-2)%2F10)%2B1))*%24C%242%3A%24C%241000%2C1))*(C2%26lt%3B%26gt%3B%22%22)%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1020646%22%20slang%3D%22en-US%22%3ERe%3A%20Conditional%20Formatting%20with%20multiple%20conditions%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1020646%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F462388%22%20target%3D%22_blank%22%3E%40Eklavya%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%20start%20from%20inside.%20The%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EINT((ROW()-2)%2F10)%2B1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ereturns%201%20if%20the%20current%20row%20is%20in%20first%2010%20records%2C%202%20for%20next%2010%2C%20etc.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20313px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158090iEA92AF4DD859A9C9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENext%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EINT((ROW(%24D%242%3A%24D%241000)-2)%2F10)%2B1)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ereturns%20the%20same%20but%20as%20array%20for%20your%20entire%20range%2C%20i.e.%20array%20like%20%7B1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C1%2C2%2C2%2C2%2C2%2C2...%7D%3C%2FP%3E%0A%3CP%3EComparing%20one%20with%20another%20we%20have%20array%20with%2010%20TRUE%20and%20with%20FALSE%20for%20the%20rest%2C%20depends%20on%20which%20row%20we%20are.%20Since%20equivalent%20of%20TRUE%20and%20FALSE%20are%201%20and%200%2C%20next%201%2F(array)%20returns%201%20for%20the%20rows%20from%20current%20ten%20and%20error%20(division%20on%20zero)%20for%20the%20rest.%3C%2FP%3E%0A%3CP%3EMultiplying%20on%20range%20values%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E*%24D%242%3A%24D%241000%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ewe%20have%20an%20array%20with%20column%20values%20for%20current%20ten%20records%20and%20others%20are%20errors.%3C%2FP%3E%0A%3CP%3EAGGREGATE%20finds%20the%20first%20(4th%20parameter%20%3D1)%20smallest%20(1st%20parameter%20%3D15)%20value%20in%20the%20array%20(third%20parameter)%20ignoring%20all%20errors%20(2nd%20parameter%20%3D%206).%3C%2FP%3E%0A%3CP%3ENext%20we%20use%20formula%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3DD2%3DAGGREGATE(...)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3Ein%20conditional%20formatting%20rule.%20CF%20iterates%20our%20entire%20range%20to%20which%20CF%20rule%20is%20applied%20starting%20from%20first%20cell%20of%20the%20range%20D2.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20for%20the%20current%20cell%20formula%20returns%20TRUE%2C%20CF%20applies%20to%20it%20defined%20in%20the%20rule%20format%20and%20do%20nothing%20in%20all%20other%20cases.%3C%2FP%3E%0A%3CP%3ERule%20in%20the%20formula%20returns%20TRUE%20if%20only%20current%20cell%20value%20is%20equal%20to%20minimum%20value%20of%20current%20ten%20returned%20by%20AGGREGATE.%3C%2FP%3E%0A%3CP%3EIn%20addition%2C%20we%20multiply%20above%20on%26nbsp%3B(D2%26lt%3B%26gt%3B0)%20to%20exclude%20from%20formatting%20all%20blank%20cells%20in%20the%20range.%20Thus%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%3D(D2%3DAGGREGATE(...))*(D2%26lt%3B%26gt%3B0)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3Bapply%20format%20if%20value%20for%20the%20current%20cell%20is%20equal%20to%20smallest%20in%20current%20ten%20AND%20cell%20is%20not%20blank.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESame%20for%20Max%2C%20but%20another%20range%20and%20first%20parameter%20in%20AGGREGATE%20is%2014%2C%20i.e.%20it%20returns%20first%20largest%20value.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Eklavya
Occasional Contributor

In the attached file I am trying to figure a way to do the following steps, in said order:

  1. Highlight row every 10th day (completed)
  2. Compare Column C values for every 10 day range and highlight in red the highest value (partially completed but need to automate it, currently have copy pasted conditional formatting for every 10 day range)
  3. Compare Column D value for every 10 day range and highlight in green the lowest value (partially completed but need to automate it, currently have copy pasted conditional formatting for every 10 day range)
  4. From 10 day range lowest value need to highlight 2 highest value's (Column C) pre and post lowest value date (need to figure this)

NOTE: New data will be added every day or week. Previous 10 day highlights should not be removed with new 10 day highlights, so if there is 6 months of data there would be ~18.25, 10 day ranges, therefore ~18 lowest value shown on the spreadsheet. Would prefer without Macro and/or VBA

4 Replies
Solution

@Eklavya 

As for 2) and 3) you may apply rules with formulas

=(D2=AGGREGATE(15,6,1/((INT((ROW()-2)/10)+1)=(INT((ROW($D$2:$D$1000)-2)/10)+1))*$D$2:$D$1000,1))*(D2<>0)

 and

=(C2=AGGREGATE(14,6,1/((INT((ROW()-2)/10)+1)=(INT((ROW($D$2:$D$1000)-2)/10)+1))*$C$2:$C$1000,1))*(C2<>"")

As for 4) - have no solution so far, not for today...

@Sergei Baklan This is good. Consulted an excel expert chat (ExcelChat by Got It,Inc), they are generally good but for this they did not have any any solution, wasted good 5-6 hours with them on this over an above trying to figure it out myself.

 

Really appreciate this.

 

The 4th one is a brain scratcher.

@Sergei Baklan If you don't mind, can you walk me through the logic of the formulae 

 

=(D2=AGGREGATE(15,6,1/((INT((ROW()-2)/10)+1)=(INT((ROW($D$2:$D$1000)-2)/10)+1))*$D$2:$D$1000,1))*(D2<>0)

 and

=(C2=AGGREGATE(14,6,1/((INT((ROW()-2)/10)+1)=(INT((ROW($D$2:$D$1000)-2)/10)+1))*$C$2:$C$1000,1))*(C2<>"")

 

@Eklavya 

Let start from inside. The

INT((ROW()-2)/10)+1)

returns 1 if the current row is in first 10 records, 2 for next 10, etc.

image.png

Next

INT((ROW($D$2:$D$1000)-2)/10)+1)

returns the same but as array for your entire range, i.e. array like {1,1,1,1,1,1,1,1,1,1,2,2,2,2,2...}

Comparing one with another we have array with 10 TRUE and with FALSE for the rest, depends on which row we are. Since equivalent of TRUE and FALSE are 1 and 0, next 1/(array) returns 1 for the rows from current ten and error (division on zero) for the rest.

Multiplying on range values

*$D$2:$D$1000

we have an array with column values for current ten records and others are errors.

AGGREGATE finds the first (4th parameter =1) smallest (1st parameter =15) value in the array (third parameter) ignoring all errors (2nd parameter = 6).

Next we use formula

=D2=AGGREGATE(...)

in conditional formatting rule. CF iterates our entire range to which CF rule is applied starting from first cell of the range D2. 

If for the current cell formula returns TRUE, CF applies to it defined in the rule format and do nothing in all other cases.

Rule in the formula returns TRUE if only current cell value is equal to minimum value of current ten returned by AGGREGATE.

In addition, we multiply above on (D2<>0) to exclude from formatting all blank cells in the range. Thus

=(D2=AGGREGATE(...))*(D2<>0)

 apply format if value for the current cell is equal to smallest in current ten AND cell is not blank.

 

Same for Max, but another range and first parameter in AGGREGATE is 14, i.e. it returns first largest value.

Related Conversations
Conditional Formatting - Consider Only Value as Lowest Value
Ben Smith in Excel on
2 Replies
conditional formatting with formula
kdwork in Excel on
3 Replies
Format Date in header and footer
Joe Cangelosi in Excel on
3 Replies
Date Formatting Won't Change
Steve Gould in Excel on
10 Replies