Code To Highlight Rows When Out Of Sequence

Dazzawm

Well-known Member
Joined
Jan 24, 2011
Messages
3,783
Office Version
  1. 365
Platform
  1. Windows
I need a code please that will highlight rows when not in order. The code needs to look at column C then see all the rows that match. In the example below the first 3 rows match so then needs to look at column AF. Because Water Pump 2 is above Water Pump 1 then the rows need to be highlighted as they are. The next set of 3 are left clear because Water Pump 1 is above Water Pump 2 so that is ok, the bottom 2 are highlighted because Water Pump 2 is above Water Pump 1 then the rows need to be highlighted as they are and so on with the rest of the rows in the file. I have hidden the rest of the columns for clarity. A sort can't be done as there is many columns with data in. There may be 2 rows that match in C or there may be 10 rows that match. Thanks.

VLAST16 7001Data1(Sell First Where Possible)
VLAST16 7001Data2Water Pump 2
VLAST16 7001Data3Water Pump 1
VLAST16 7004Data4(Sell First Where Possible)
VLAST16 7004Data5Water Pump 1
VLAST16 7004Data6Water Pump 2
VLAST16 5022Data4Water Pump 2
VLAST16 5022Data5Water Pump 1
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I used conditional formatting for this:

MrExcelPlayground19.xlsx
CAEAF
2VLAST16 7001Data1(Sell First Where Possible)
3VLAST16 7001Data2Water Pump 2
4VLAST16 7001Data3Water Pump 1
5VLAST16 7004Data4(Sell First Where Possible)
6VLAST16 7004Data5Water Pump 1
7VLAST16 7004Data6Water Pump 2
8VLAST16 5022Data4Water Pump 2
9VLAST16 5022Data5Water Pump 1
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:AF9Expression=LET(a,FILTER($C$2:$AF$9,$C$2:$C$9=$C2),b,TAKE(a,,-1),d,FIND("/", SUBSTITUTE(b," ","/", LEN(b)-LEN(SUBSTITUTE(b," ","")))),e,VALUE(MID(b,d,99)),f,FILTER(e,NOT(ISERR(e))),g,VSTACK(0,DROP(f,-1)),h,AND(f-g>0),NOT(h))textNO
 
Upvote 0
I used conditional formatting for this:

MrExcelPlayground19.xlsx
CAEAF
2VLAST16 7001Data1(Sell First Where Possible)
3VLAST16 7001Data2Water Pump 2
4VLAST16 7001Data3Water Pump 1
5VLAST16 7004Data4(Sell First Where Possible)
6VLAST16 7004Data5Water Pump 1
7VLAST16 7004Data6Water Pump 2
8VLAST16 5022Data4Water Pump 2
9VLAST16 5022Data5Water Pump 1
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C2:AF9Expression=LET(a,FILTER($C$2:$AF$9,$C$2:$C$9=$C2),b,TAKE(a,,-1),d,FIND("/", SUBSTITUTE(b," ","/", LEN(b)-LEN(SUBSTITUTE(b," ","")))),e,VALUE(MID(b,d,99)),f,FILTER(e,NOT(ISERR(e))),g,VSTACK(0,DROP(f,-1)),h,AND(f-g>0),NOT(h))textNO
Thanks but I need a macro please as its to be used on many files (personal macro workbook) and much data on each so formulas are no good.
 
Upvote 0
I assume Row 1 is a header row and data starts in A2. Is that correct?

What cells do you want highlighted, the entire table row or just cells in columns C and AF?
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

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