Duplicate Conditional Formatting, reset after range End

motilulla

Well-known Member
Joined
Feb 13, 2008
Messages
2,422
Office Version
  1. 2010
Hello,

I am looking a VBA or Formula, which can highlight duplicate in the range till "End" find in the column "J", and then start again as a new range till find next "End" in column "J"

For example...
1st range would be D6:H12 highlight duplicate in colour Cyan and row 12-font colour in Red

1st range would be D13:H18 highlight duplicate in colour Yellow and row 18-font colour in Red

To do this I have use formula and adjusted ranges manually, my query is that can be done with one Formula Or VBA automatically please help

For more detail image is attached

*ABCDEFGHIJKLMNO
1
2
3
4
5n1n2n3n4n5StatusRangeFormulaCondition
62434354246
72027344650Range D7:H12Formula =--ISNUMBER(MATCH(D7,D$6:D6,0))Fill Colour = Cyan
81117214850Range D7:H12Formula =IF($J7="End",1,0)End Row Font Colour = Red
9116384245
101117183944
111315303542
12615223744End
13310232744
1467383944Range D14:H18Formula =--ISNUMBER(MATCH(D14,D$13:D13,0))Fill Colour = Yellow
15419234143Range D14:H18Formula =IF($J14="End",1,0)End Row Font Colour = Red
16325274849
172023263033
18416213644End
19916181921
201417282939Range D20:H24Formula =--ISNUMBER(MATCH(D20,D$19:D19,0))Fill Colour = Cyan
21217222740Range D20:H24Formula =IF($J20="End",1,0)End Row Font Colour = Red
223132224042
2313162437
24818163537End
2527244346
261019234549Range D26:H32Formula =--ISNUMBER(MATCH(D26,D$25:D25,0))Fill Colour = Yellow
27416182544Range D26:H32Formula =IF($J26="End",1,0)End Row Font Colour = Red
281471050
291116243840
301336404350
3135344049
321327244243End
33132354548
3478242736Range D34:H39Formula =--ISNUMBER(MATCH(D34,D$33:D33,0))Fill Colour = Cyan
35620242550Range D34:H39Formula =IF($J34="End",1,0)End Row Font Colour = Red
3678192829
37717222740
38813263438
392728293443End
40
41
42

Thank you all.

I am using Excel 2000

Regards,
Moti
 

Attachments

  • CF Duplicate Range By Range.png
    CF Duplicate Range By Range.png
    70.8 KB · Views: 7

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
wow this is some condition:
MrExcel Playbook 01 2021-08.xlsm
DEFGHIJ
5n1n2n3n4n5Status
62434354246
72027344650
81117214850
9116384245
101117183944
111315303542
12615223744End
13310232744
1467383944
15419234143
16325274849
172023263033
18416213644End
19916181921
201417282939
21217222740
223132224042
2313162437
24818163537End
2527244346
261019234549
27416182544
281471050
291116243840
301336404350
3135344049
321327244243End
33132354548
3478242736
35620242550
3678192829
37717222740
38813263438
392728293443End
CF
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:J39Expression=$J6="End"textNO
D6:H39Expression=ISNUMBER(MATCH(D6,OFFSET(D6,IFERROR(LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5)),ROW($J$5))-ROW()+1,0,ROW()-IFERROR(LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5)),ROW($J$5))-1,1),0))*(MOD(COUNTIF($J$5:$J5,"End"),2)=0)textYES
D6:H39Expression=ISNUMBER(MATCH(D6,OFFSET(D6,IFERROR(LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5)),ROW($J$5))-ROW()+1,0,ROW()-IFERROR(LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5)),ROW($J$5))-1,1),0))*(MOD(COUNTIF($J$5:$J5,"End"),2)=1)textNO
 
Upvote 0
wow this is some condition:
bobsan42, i am very great full to you for building a huge formula, I applied as you explained but it did not worked...searching a bit I found that "IFERROR" is not compatible with my Excel 2000.

Thank you for your help

Good Luck! Have a good day

Kind Regards,
Moti
 
Upvote 0
bobsan42, i am very great full to you for building a huge formula, I applied as you explained but it did not worked...searching a bit I found that "IFERROR" is not compatible with my Excel 2000.

Thank you for your help

Good Luck! Have a good day

Kind Regards,
Moti
Yes, Fluff pointed my oversight. Still there is a workaround - Replace the word Status in J5 with End and try the following:
MrExcel Playbook 01 2021-08.xlsm
DEFGHIJ
5n1n2n3n4n5End
62434354246
72027344650
81117214850
9116384245
101117183944
111315303542
12615223744End
13310232744
1467383944
15419234143
16325274849
172023263033
18416213644End
19916181921
201417282939
21217222740
223132224042
2313162437
24818163537End
2527244346
261019234549
27416182544
281471050
291116243840
301336404350
3135344049
321327244243End
33132354548
3478242736
35620242550
3678192829
37717222740
38813263438
392728293443End
CF (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:J39Expression=$J6="End"textNO
D6:H39Expression=ISNUMBER(MATCH(D6,OFFSET(D6,LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5))-ROW()+1,0,ROW()-LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5))-1,1),0))*(MOD(COUNTIF($J$5:$J5,"End"),2)=1)textYES
D6:H39Expression=ISNUMBER(MATCH(D6,OFFSET(D6,LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5))-ROW()+1,0,ROW()-LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5))-1,1),0))*(MOD(COUNTIF($J$5:$J5,"End"),2)=0)textNO
 
Upvote 0
Yes, Fluff pointed my oversight. Still there is a workaround - Replace the word Status in J5 with End and try the following:
bobsan42, Wow It worked fine as treat really I appreciate your kind help and time you dedicate to find the solution I am happy, but it is problem from my side using an old version and not a very modern computer so after applying a this formula to original layout nearly 10000+ rows when I scroll my screen is flickering and slow down the worksheet.

I think may I require a VBA solution not sure that will help or not.

I am gratefully to you. Good Luck! Have a good day

Kind Regards,
Moti :)
 
Upvote 0
You can use helper columns to reduce the size of the conditions and simplify them.
But still many and complex CFs may have negative effect on performance.
 
Upvote 0
With two Additional helper columns (A and B) the performance improvement is significant on 6.5 K lines.
Try it like this:
MrExcel Playbook 01 2021-08.xlsm
ABCDEFGHIJ
5GroupRowsn1n2n3n4n5End
6102434354246
71-12027344650
81-21117214850
91-3116384245
101-41117183944
111-51315303542
121-6615223744End
1300310232744
140-167383944
150-2419234143
160-3325274849
170-42023263033
180-5416213644End
1910916181921
201-11417282939
211-2217222740
221-33132224042
231-413162437
241-5818163537End
250027244346
260-11019234549
270-2416182544
280-31471050
290-41116243840
300-51336404350
310-635344049
320-71327244243End
3310132354548
341-178242736
351-2620242550
361-378192829
371-4717222740
381-5813263438
391-62728293443End
CF (3)
Cell Formulas
RangeFormula
A6:A39A6=MOD(COUNTIF($J$5:$J5,"End"),2)
B6:B39B6=LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5))-ROW()+1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:J6125Expression=$J6="End"textNO
D6:J6125Expression=ISNUMBER(MATCH(D6,OFFSET(D6,$B6,0,-$B6,1),0))*($A6=1)textYES
D6:J6125Expression=ISNUMBER(MATCH(D6,OFFSET(D6,$B6,0,-$B6,1),0))*($A6=0)textNO
 
Upvote 0
Solution
With two Additional helper columns (A and B) the performance improvement is significant on 6.5 K lines.
Try it like this:
MrExcel Playbook 01 2021-08.xlsm
ABCDEFGHIJ
5GroupRowsn1n2n3n4n5End
6102434354246
71-12027344650
81-21117214850
91-3116384245
101-41117183944
111-51315303542
121-6615223744End
1300310232744
140-167383944
150-2419234143
160-3325274849
170-42023263033
180-5416213644End
1910916181921
201-11417282939
211-2217222740
221-33132224042
231-413162437
241-5818163537End
250027244346
260-11019234549
270-2416182544
280-31471050
290-41116243840
300-51336404350
310-635344049
320-71327244243End
3310132354548
341-178242736
351-2620242550
361-378192829
371-4717222740
381-5813263438
391-62728293443End
CF (3)
Cell Formulas
RangeFormula
A6:A39A6=MOD(COUNTIF($J$5:$J5,"End"),2)
B6:B39B6=LOOKUP(2,1/($J$5:$J5="End"),ROW($J$5:$J5))-ROW()+1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:J6125Expression=$J6="End"textNO
D6:J6125Expression=ISNUMBER(MATCH(D6,OFFSET(D6,$B6,0,-$B6,1),0))*($A6=1)textYES
D6:J6125Expression=ISNUMBER(MATCH(D6,OFFSET(D6,$B6,0,-$B6,1),0))*($A6=0)textNO
Superb! bobsan42, yes true helper columns did the trick and improved the performance now all worked as it should. (y)

I appreciate your kind help thank you for resolving it.

Good Luck! Have a good day

Kind Regards,
Moti :)
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,151
Members
452,891
Latest member
JUSTOUTOFMYREACH

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