color cell if the time value for a given unit is within a range

%3CLINGO-SUB%20id%3D%22lingo-sub-1360827%22%20slang%3D%22en-US%22%3Ecolor%20cell%20if%20the%20time%20value%20for%20a%20given%20unit%20is%20within%20a%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1360827%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20color%20the%20time%20cells%20red%20if%20the%20time%20differnces%20for%20a%20specified%20unit%20is%20less%20than%2010%20minutes.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%2C%20for%20unit%203813%20if%20any%20of%20the%20first%2C%20second%2C%20third%2C%20fourth%20time%20values%20are%20within%2010%20minute%20of%20each%20other%20then%20they%20should%20be%20higlighted%20red.%20Thanks%3C%2FP%3E%3CTABLE%20width%3D%22206%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22121%22%3E2020-05-01%2010%3A01%3A00%3C%2FTD%3E%3CTD%20width%3D%2285%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2009%3A56%3A00%3C%2FTD%3E%3CTD%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2009%3A50%3A00%3C%2FTD%3E%3CTD%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2008%3A33%3A00%3C%2FTD%3E%3CTD%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2012%3A29%3A00%3C%2FTD%3E%3CTD%3E3959%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2016%3A42%3A00%3C%2FTD%3E%3CTD%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2015%3A10%3A00%3C%2FTD%3E%3CTD%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2013%3A30%3A00%3C%2FTD%3E%3CTD%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2011%3A51%3A00%3C%2FTD%3E%3CTD%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2010%3A15%3A00%3C%2FTD%3E%3CTD%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2008%3A27%3A00%3C%2FTD%3E%3CTD%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2016%3A46%3A00%3C%2FTD%3E%3CTD%3E4838%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2015%3A39%3A00%3C%2FTD%3E%3CTD%3E4838%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2014%3A33%3A00%3C%2FTD%3E%3CTD%3E4838%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2013%3A24%3A00%3C%2FTD%3E%3CTD%3E4838%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%3E2020-05-01%2012%3A22%3A00%3C%2FTD%3E%3CTD%3E4838%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1360827%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1361167%22%20slang%3D%22en-US%22%3ERe%3A%20color%20cell%20if%20the%20time%20value%20for%20a%20given%20unit%20is%20within%20a%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1361167%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F656583%22%20target%3D%22_blank%22%3E%40jiwanjot%3C%2FA%3E%26nbsp%3B%2C%20apply%20below%20formula%20in%20conditional%20formatting%20on%20time%20cells%20as%20shown%20%3A-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20file%20is%20also%20attached%20for%20ref.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22amit_bhola_0-1588704586260.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F189172i79672DB2CEB8B466%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22amit_bhola_0-1588704586260.png%22%20alt%3D%22amit_bhola_0-1588704586260.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1361604%22%20slang%3D%22en-US%22%3ERe%3A%20color%20cell%20if%20the%20time%20value%20for%20a%20given%20unit%20is%20within%20a%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1361604%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F636579%22%20target%3D%22_blank%22%3E%40amit_bhola%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20this.%20But%20it%20still%20doesnot%20color%20all%20cells%3C%2FP%3E%3CP%3EThis%20time%20does%20not%20get%20highlighted%3C%2FP%3E%3CTABLE%20width%3D%22206px%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%3E2020-05-01%2009%3A50%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ealso%20i%20dont%20think%20this%20formula%20works%20if%20same%20time%20values%20are%20seperated%20by%20more%20than%20one%20cell%3C%2FP%3E%3CTABLE%20width%3D%22206%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2011%3A35%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3642%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2010%3A10%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3642%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2008%3A17%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3642%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2016%3A34%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2014%3A53%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2009%3A48%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2012%3A15%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2011%3A14%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2010%3A05%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2010%3A01%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2009%3A56%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2009%3A50%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2008%3A33%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3813%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2009%3A48%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E3959%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2016%3A42%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2015%3A10%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2013%3A30%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2011%3A51%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2010%3A15%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E4344%3C%2FTD%3E%3C%2FTR%3E%3CTR%3E%3CTD%20width%3D%22120.667px%22%20height%3D%2256px%22%3E2020-05-01%2008%3A27%3A00%3C%2FTD%3E%3CTD%20width%3D%2284.6667px%22%20height%3D%2256px%22%3E4344%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1362058%22%20slang%3D%22en-US%22%3ERe%3A%20color%20cell%20if%20the%20time%20value%20for%20a%20given%20unit%20is%20within%20a%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1362058%22%20slang%3D%22en-US%22%3E1.%20Regarding%20the%203rd%20cell%20not%20getting%20colored%2C%20it%20is%20easy%20%3A%20current%20conditional%20format%20formula%20from%20A1~Aend%20checks%20%22self%20cell%20and%20cell%20*below*%20%22%3CBR%20%2F%3Efor%20time%20difference.%20One%20can%20add%20another%20such%20conditional%20formatting%20rule%20with%20another%20similar%20formula%20on%20range%20A2~onwards%20which%20but%20checks%20%22self%20cell%20and%20cell%20*above*%20%22%3CBR%20%2F%3EBoth%20above%202%20rules%20when%20applied%20together%20would%20color%20both%20cells%20for%20each%20continuous%20pair.%3CBR%20%2F%3E%3CBR%20%2F%3E2.%20As%20for%20cells%20separated%20by%20more%20than%20one%20cell%2C%20if%20situation%20permits%2C%20data%20may%20be%20sorted%20first%20using%20data%20sort%20dialogue%20box%2C%20with%202%20levels%20of%20sorts%20%3A%20first%20by%20unit%20no.%20and%20next%20level%20by%20time.%20Then%20more%20than%20one%20cell%20separation%20case%20won't%20exist.%20After%20sorting%2C%20conditional%20formatting%20rule%20to%20be%20applied.%3CBR%20%2F%3E%3CBR%20%2F%3E3.%20If%20situation%20doesn't%20permit%20data%20sorting%2C%20then%2C%20probably%20it%20needs%20creating%20a%20loop%20(macro%20programming)%2C%20which%20is%20not%20possible%20by%20excel%20sheet%20formulas.%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1362067%22%20slang%3D%22en-US%22%3ERe%3A%20color%20cell%20if%20the%20time%20value%20for%20a%20given%20unit%20is%20within%20a%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1362067%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F656583%22%20target%3D%22_blank%22%3E%40jiwanjot%3C%2FA%3E%26nbsp%3B%2C%20Like%20below%20%3A-%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ein%20fact%20same%20formula%20is%20now%20applied%20twice%20%3A%20once%20on%20A1%20to%20A15%20%26amp%3B%20then%20again%20on%20A2%20to%20A16%3C%2FP%3E%3CP%3ESee%20yellow%20highlighted%20in%20screenshot%20that%20follows%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA1%20to%20A15%20rule%20%3A%20checks%20self%20and%20cell%20%3CSTRONG%3Ebelow%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EA2%20to%20A16%20rule%20%3A%20checks%20self%20and%20cell%20%3CSTRONG%3Eabove%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20combination%2C%20these%20two%20rules%20work%20fine%20for%20continuous%20cells%20with%20time%20differenc%20%26lt%3B10min%3C%2FP%3E%3CP%3EHere%20i%20changed%20some%20time%20values%20as%20test%20case%20to%20show%20it%20works%20%3A-%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESee%20modified%20attachment%20of%20this%20post%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22amit_bhola_0-1588732724538.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F189377i64CDC92C52A5B919%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22amit_bhola_0-1588732724538.png%22%20alt%3D%22amit_bhola_0-1588732724538.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20for%20non-continuous%20cells%2C%20i'm%20afraid%20i%20can%20think%20of%20sorting%20as%20only%20option%20in%20excel%20formulas%20(i.e.%20without%20involving%20macro%20programing)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1364910%22%20slang%3D%22en-US%22%3ERe%3A%20color%20cell%20if%20the%20time%20value%20for%20a%20given%20unit%20is%20within%20a%20range%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1364910%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F636579%22%20target%3D%22_blank%22%3E%40amit_bhola%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%20sort%20works%20I%20sorted%20first%20with%20unit%20and%20then%20by%20time.%3C%2FP%3E%3CP%3EThank%20you%20so%20much%20for%20your%20help%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

Hi All,

I am trying to color the time cells red if the time differnces for a specified unit is less than 10 minutes.

 

For example, for unit 3813 if any of the first, second, third, fourth time values are within 10 minute of each other then they should be higlighted red. Thanks

2020-05-01 10:01:003813
2020-05-01 09:56:003813
2020-05-01 09:50:003813
2020-05-01 08:33:003813
2020-05-01 12:29:003959
2020-05-01 16:42:004344
2020-05-01 15:10:004344
2020-05-01 13:30:004344
2020-05-01 11:51:004344
2020-05-01 10:15:004344
2020-05-01 08:27:004344
2020-05-01 16:46:004838
2020-05-01 15:39:004838
2020-05-01 14:33:004838
2020-05-01 13:24:004838
2020-05-01 12:22:004838
5 Replies
Highlighted

@jiwanjot , apply below formula in conditional formatting on time cells as shown :-

 

This file is also attached for ref.

 

amit_bhola_0-1588704586260.png

 

Highlighted

@amit_bhola 

 

Thanks for this. But it still doesnot color all cells

This time does not get highlighted

2020-05-01 09:50:003813

 

also i dont think this formula works if same time values are seperated by more than one cell

2020-05-01 11:35:003642
2020-05-01 10:10:003642
2020-05-01 08:17:003642
2020-05-01 16:34:003813
2020-05-01 14:53:003813
2020-05-01 09:48:003813
2020-05-01 12:15:003813
2020-05-01 11:14:003813
2020-05-01 10:05:003813
2020-05-01 10:01:003813
2020-05-01 09:56:003813
2020-05-01 09:50:003813
2020-05-01 08:33:003813
2020-05-01 09:48:003959
2020-05-01 16:42:004344
2020-05-01 15:10:004344
2020-05-01 13:30:004344
2020-05-01 11:51:004344
2020-05-01 10:15:004344
2020-05-01 08:27:004344
Highlighted
1. Regarding the 3rd cell not getting colored, it is easy : current conditional format formula from A1~Aend checks "self cell and cell *below* "
for time difference. One can add another such conditional formatting rule with another similar formula on range A2~onwards which but checks "self cell and cell *above* "
Both above 2 rules when applied together would color both cells for each continuous pair.

2. As for cells separated by more than one cell, if situation permits, data may be sorted first using data sort dialogue box, with 2 levels of sorts : first by unit no. and next level by time. Then more than one cell separation case won't exist. After sorting, conditional formatting rule to be applied.

3. If situation doesn't permit data sorting, then, probably it needs creating a loop (macro programming), which is not possible by excel sheet formulas.
Highlighted

@jiwanjot , Like below :- 

 

in fact same formula is now applied twice : once on A1 to A15 & then again on A2 to A16

See yellow highlighted in screenshot that follows

 

A1 to A15 rule : checks self and cell below

A2 to A16 rule : checks self and cell above

 

In combination, these two rules work fine for continuous cells with time differenc <10min

Here i changed some time values as test case to show it works :-

 

See modified attachment of this post

 

amit_bhola_0-1588732724538.png

 

and for non-continuous cells, i'm afraid i can think of sorting as only option in excel formulas (i.e. without involving macro programing)

 

Highlighted

@amit_bhola 

 

Yes sort works I sorted first with unit and then by time.

Thank you so much for your help