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

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,751
Office Version
  1. 365
Platform
  1. Windows
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
KLMNOPQ
1IdentifierSMSYEMEY
2M10306960000001031994121997
3M10306960000001031994121997
4M10306960000001031994121997
5M10306960000002031994121995
6M10306960000002031994121999
7M10306960000002031994121999
8M18912550000000062016122016
9M18912550000000062016122016
10M18912550000000062016122016
11M18900900000001022015122015
12M18900900000001022015
13M18900900000001022015
14M18900900000002022015
15M18900900000002022015
16M18900900000002022015
17M18912170000009042015042017
18M18912170000009042016042017
19M18912170000002022015122015
20M18912170000002012016122016
21M18912170000002012017
22M18912170000007052016
23M18912170000007052016
24M18912170000007052016

<colgroup><col style="width: 25pxpx" https:="" www.mrexcel.com="" forum="" usertag.php?do="list&action=hash&hash=DAE7F5"" target="_blank"></colgroup><colgroup><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>

Edit

In hindsight its probably better if the code looks for matches in column C rather than K please.
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
M10306960000001031994121997
5M10306960000002031994121995

is the 001 the same as 002

<tbody>
</tbody>
 
Upvote 0
No its a different number, they need to match in C (K)
 
Upvote 0
sorry - but I still do not know what you want - try asking again with a pretend scenario eg fruit prices or whatever
 
Upvote 0
1. Data needs to match in column C.
2. It then needs to look at start and end dates.
3. If the rows match in C the date range in N & O should always be equal or later to the date range of P & Q of the previous row.
 
Upvote 0
row 5 first time number has appeared so why is it yellow - if it is the same in row C why not show us rows C to Q
 
Upvote 0
I don't think it is necessary for you to see what is between C & Q plus its sensitive data. And I don't understand your post 12, I don't know where the 5 came from.
 
Upvote 0
sensitive data - overwrite it with random numbers

iddateamountlower
101/04/201827
202/04/201831
303/04/201835
404/04/201839
105/04/201843
201/04/201847L
307/04/201851
408/04/201855
109/04/201859
210/04/201863
311/04/201867
412/04/201871
108/04/201875L
214/04/201879
315/04/201883
416/04/201887
is this correct

<colgroup><col><col><col span="3"></colgroup><tbody>
</tbody>
 
Upvote 0
In your original post, row 3 (03/1994) is less than row 2 (12/1997) yet it's not flagged as incorrect. What makes this row correct? Also, if an error is found, do you want to highlight all rows containing that identifier?

WBD
 
Upvote 0
Quick first draft of code give this:


Book1
CDEFGHIJKLMNOPQ
1IdentifierIdentifierSMSYEMEY
2M10306960000001M1030696000000131994121997
3M10306960000001M1030696000000131994121997
4M10306960000001M1030696000000131994121997
5M10306960000002M1030696000000231994121995
6M10306960000002M1030696000000231994121999
7M10306960000002M1030696000000231994121999
8M18912550000000M1891255000000062016122016
9M18912550000000M1891255000000062016122016
10M18912550000000M1891255000000062016122016
11M18900900000001M1890090000000122015122015
12M18900900000001M1890090000000122015
13M18900900000001M1890090000000122015
14M18900900000002M1890090000000222015
15M18900900000002M1890090000000222015
16M18900900000002M1890090000000222015
17M18912170000009M189121700000094201542017
18M18912170000009M189121700000094201642017
19M18912170000002M1891217000000222015122015
20M18912170000002M1891217000000212016122016
21M18912170000002M1891217000000212017
22M18912170000007M1891217000000752016
23M18912170000007M1891217000000752016
24M18912170000007M1891217000000752016
Sheet1


WBD
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,730
Members
449,465
Latest member
TAKLAM

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top