Find Groups and Highlight them

motilulla

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

I have some set of 6 numbers in the range A2:F24 I want to find groups of consecutive numbers (2, 3, 4, 5 and 6) in the range H2:L2 and then highlight groups in different colours in the range A2:F24. Need a VBA solution.

n1n2n3n4n5n6Count Consequtives Group of 2 NumbersCount Consequtives Group of 3 NumbersCount Consequtives Group of 4 NumbersCount Consequtives Group of 5 NumbersCount Consequtives Group of 6 Numbers
1​
2​
3​
4​
5​
6​
1
1​
2​
10​
12​
22​
35​
1
1​
2​
3​
34​
36​
38​
1
1​
8​
20​
24​
33​
35​
1​
10​
14​
24​
28​
35​
1​
11​
16​
17​
29​
33​
1
2​
12​
33​
34​
35​
36​
1
14​
15​
18​
19​
34​
35​
3
16​
17​
18​
22​
23​
24​
2
2​
19​
20​
21​
22​
36​
1
4​
27​
29​
31​
36​
38​
5​
7​
10​
17​
21​
32​
5​
7​
15​
16​
17​
39​
1
6​
8​
12​
18​
20​
27​
8​
9​
10​
22​
24​
36​
1
8​
10​
16​
25​
26​
39​
1
8​
11​
17​
20​
22​
34​
8​
9​
10​
11​
12​
37​
1
12​
19​
23​
28​
36​
39​
13​
16​
25​
28​
36​
38​
16​
19​
28​
30​
31​
38​
1
17​
21​
26​
27​
34​
36​
1
18​
34​
35​
36​
37​
39​
1

Regards,
Moti
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

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