Excel: Code to highlight rows when data range is before previous date.


Tricky one to explain this. I have a file where I need to know if any row of dates are earlier than the rows before. The code first needs to look at column K and all the numbers that match. In the example below I have highlighted in yellow the ones that are incorrect. If you look at N6&7/O6&7 the date is earlier than P5/Q5 above. The same with N12&13/O12&13 is earlier than P11/Q11. The ones in blue are as it should be, they all follow on from each other. Like I say difficult to explain but please let me know if more clarification is needed. Excel 2010

K L M N O P Q
1 Identifier SM SY EM EY
2 M10306960000001 03 1994 12 1997
3 M10306960000001 03 1994 12 1997
4 M10306960000001 03 1994 12 1997
5 M10306960000002 03 1994 12 1995
6 M10306960000002 03 1994 12 1999
7 M10306960000002 03 1994 12 1999
8 M18912550000000 06 2016 12 2016
9 M18912550000000 06 2016 12 2016
10 M18912550000000 06 2016 12 2016
11 M18900900000001 02 2015 12 2015
12 M18900900000001 02 2015
13 M18900900000001 02 2015
14 M18900900000002 02 2015
15 M18900900000002 02 2015
16 M18900900000002 02 2015
17 M18912170000009 04 2015 04 2017
18 M18912170000009 04 2016 04 2017
19 M18912170000002 02 2015 12 2015
20 M18912170000002 01 2016 12 2016
21 M18912170000002 01 2017
22 M18912170000007 05 2016
23 M18912170000007 05 2016
24 M18912170000007 05 2016
[CENTER] [/CENTER] Edit In hindsight its probably better if the code looks for matches in column C rather than K please.


This question generated 21 answers. To proceed to the answers, click here.

This thread is current as of May 01, 2018.


For more resources for Microsoft Excel