Highlight consecutive(sequential) numbers in excel

Samgraphics

Board Regular
Joined
Jan 9, 2022
Messages
61
Office Version
  1. 2011
Platform
  1. MacOS
Hi, can someone please help me? I'm trying to highlight combinations of numbers if they increase incrementally, example 1,2,3,4,5 or combination where the interval is increasing at the same rate like 5,12,20,29,39 or combinations with equal intervals like 2,4,6,8,10. So any combinations like the ones I highlighted below would be highlighted.

Thank you in advance

All combinations 2023-24.xlsm
CDEFG
112345
212346
312347
412348
512349
6246810
DA LUO TO
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1Expression=IF(AND(C1=D1-1, D1=E1-1, E1=F1-1, F1=G1-1), "Consecutive", "Not Consecutive")textNO
 
Please be careful with your 'quotes' and only quote relevant posts or parts of them. I have just removed three quotes from your last post that, as far as I can see, had nothing to do with this follow-up question.


Could you give some sample data and expected results with XL2BB so that we can see what range(s) you are working with and how you would want the results presented? Make sure that there are some examples where there are 3 (or more?) consecutive numbers and some examples where there are no sets of 3 consecutive numbers.
Hi, thank you for your reply. Here is an example,

All combinations 2023-24.xlsm
JKLMN
20719262728
21618232732
22214162830
231792529
24511121333
2528163134
2648101421
276782533
DA LUO TO
 
Upvote 0

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.
Thanks for the samples. Try this

23 12 17.xlsm
JKLMN
20719262728
21618232732
22214162830
231792529
24511121333
2528163134
2648101421
276782533
3 consecutive
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J20:N27Expression=FIND("|1|1|","|"&$K20-$J20&"|"&$L20-$K20&"|"&$M20-$L20&"|"&$N20-$M20&"|")textNO
 
Upvote 0
Thanks for the samples. Try this

23 12 17.xlsm
JKLMN
20719262728
21618232732
22214162830
231792529
24511121333
2528163134
2648101421
276782533
3 consecutive
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J20:N27Expression=FIND("|1|1|","|"&$K20-$J20&"|"&$L20-$K20&"|"&$M20-$L20&"|"&$N20-$M20&"|")textNO
Thank you very much, it's working the way I want, but it's a bit overworking. What I mean is it's also highlighting a little bit outside the scope of what I want. It's highlighting combinations with more than 3 consecutive numbers and you already helped me with a formula to do that. Is there a way to make it highlight exclusively combinations that have only three consecutive numbers? for example, if a combination has 4 or more consecutive numbers I'd like it to exclude them. For example, it will highlight 1,2,3,410 and I don't want that. I'll show you what I mean.

All combinations 2023-24.xlsm
CDEFG
112345
212346
312347
412348
512349
6123410
7123411
8123412
9123413
10123414
11123415
12123416
DA LUO TO
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:G98280Expression=COUNTIFS($J$1:$J$98280,$C1,$K$1:$K$98280,$D1,$L$1:$L$98280,$E1,$M$1:$M$98280,$F1,$N$1:$N$98280,$G1)textNO
C1:G98280Expression=MIN($D1:$G1-$C1:$F1)=MAX($D1:$G1-$C1:$F1)textNO
C1:G98280Expression=MIN(($E1:$G1-$D1:$F1)-($D1:$F1-$C1:$E1))=MAX(($E1:$G1-$D1:$F1)-($D1:$F1-$C1:$E1))textNO
C1:G324632Expression=FIND("|1|1|","|"&$D1-$C1&"|"&$E1-$D1&"|"&$F1-$E1&"|"&$G1-$F1&"|")textNO


All combinations 2023-24.xlsm
CDEFG
46240126303435
46241126313233
46242126313234
46243126313235
46244126313334
46245126313335
46246126313435
46247126323334
46248126323335
46249126323435
46250126333435
46251127282930
46252127282931
46253127282932
46254127282933
46255127282934
46256127282935
46257127283031
46258127283032
DA LUO TO
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:G98280Expression=COUNTIFS($J$1:$J$98280,$C1,$K$1:$K$98280,$D1,$L$1:$L$98280,$E1,$M$1:$M$98280,$F1,$N$1:$N$98280,$G1)textNO
C1:G98280Expression=MIN($D1:$G1-$C1:$F1)=MAX($D1:$G1-$C1:$F1)textNO
C1:G98280Expression=MIN(($E1:$G1-$D1:$F1)-($D1:$F1-$C1:$E1))=MAX(($E1:$G1-$D1:$F1)-($D1:$F1-$C1:$E1))textNO
C1:G324632Expression=FIND("|1|1|","|"&$D1-$C1&"|"&$E1-$D1&"|"&$F1-$E1&"|"&$G1-$F1&"|")textNO


Thank you so much. Also, if you wouldn't mind, explain how this formula works. I saw this "|" and I noticed it removes the border from the cells.
Thank you so much for your help and time.
 
Upvote 0
It's highlighting combinations with more than 3 consecutive numbers and you already helped me with a formula to do that.
Not exactly. What I helped with was if all 5 numbers were consecutive (or all 5 had an equal gap). My previous suggestions would not highlight if 4 of the numbers were consecutive but not 5.

What I mean is it's also highlighting a little bit outside the scope of what I want.
Make sure that there are some examples where there are 3 (or more?) consecutive numbers and some examples where there are no sets of 3 consecutive numbers.
Perhaps now then you see why I asked that before? ;)
None of your examples in post #11 had more than 3 consecutive numbers.

Try this instead.

Samgraphics.xlsm
CDEFG
112345
212346
312347
412348
512349
6123410
7123411
8123412
9123413
10123414
11123415
121231016
13
14126303435
15126313233
16126313234
17126313235
18126313334
19126313335
20126313435
21126323334
22126323335
23126323435
24126333435
25127282930
26127282931
27127282932
28127282933
29127282934
30127282935
31127283031
32127283032
3 consecutive (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:G32Expression=AND(FIND("|1|1|","|"&$D1-$C1&"|"&$E1-$D1&"|"&$F1-$E1&"|"&$G1-$F1&"|"),ISERROR(FIND("|1|1|1|","|"&$D1-$C1&"|"&$E1-$D1&"|"&$F1-$E1&"|"&$G1-$F1&"|")))textNO
 
Upvote 0
Not exactly. What I helped with was if all 5 numbers were consecutive (or all 5 had an equal gap). My previous suggestions would not highlight if 4 of the numbers were consecutive but not 5.



Perhaps now then you see why I asked that before? ;)
None of your examples in post #11 had more than 3 consecutive numbers.

Try this instead.

Samgraphics.xlsm
CDEFG
112345
212346
312347
412348
512349
6123410
7123411
8123412
9123413
10123414
11123415
121231016
13
14126303435
15126313233
16126313234
17126313235
18126313334
19126313335
20126313435
21126323334
22126323335
23126323435
24126333435
25127282930
26127282931
27127282932
28127282933
29127282934
30127282935
31127283031
32127283032
3 consecutive (2)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C1:G32Expression=AND(FIND("|1|1|","|"&$D1-$C1&"|"&$E1-$D1&"|"&$F1-$E1&"|"&$G1-$F1&"|"),ISERROR(FIND("|1|1|1|","|"&$D1-$C1&"|"&$E1-$D1&"|"&$F1-$E1&"|"&$G1-$F1&"|")))textNO
Thank you so much and yes I totally get it now, sorry again. Thank you once again.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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