Count history by colours or by the group

Kishan

Well-known Member
Joined
Mar 15, 2011
Messages
1,648
Office Version
  1. 2010
Platform
  1. Windows
Hi,</SPAN></SPAN>

I got patterns divide by 3 groups as shown in the cells C1:F3, and the conditional formula in the Column D6 to down is applied by formula is find under this link
</SPAN></SPAN>
https://www.mrexcel.com/forum/excel...er-group-pattern-post5138986.html#post5138986
</SPAN></SPAN>

What I need to count D6 below pattern by their colour or by the group as appeared in the column D
</SPAN></SPAN>

And the historical count I need that the counts be shown in the column F6 to down as per their colours or by group and cell should be coloured as per coloured count to know which count corresponds to which colour or groups
</SPAN></SPAN>

Result data example
</SPAN></SPAN>


Book1
ABCDEFGH
1Group11|1
2Group21|X1|2X|12|1
3Group3X|XX|22|X2|2
4
5Seriol nPatternsCount By Patt
61X|15
721|X2
831|X2
941|X1
105X|11
116X|X3
1272|X1
138X|11
1491|X3
1510X|21
16111|11
17121|22
18131|X3
19141|X1
20151|14
2116X|11
22171|16
23181|12
24191|11
25201|21
26211|11
2722X|X1
2823X|23
29241|X1
30252|11
31261|X1
32271|11
33282|11
3429X|11
35301|21
3631X|11
37322|X1
38331|X1
3934X|12
40351|X2
41361|X2
42371|22
4338X|12
44392|X1
4540X|21
46411|X1
4742X|X2
48431|11
4944X|X2
50451|13
51461|16
52471|11
53482|X2
54491|X4
55501|11
5651X|12
57521|1
58531|2
59541|1
60551|2
61561|1
62572|1
63581|1
64591|1
65601|2
66611|2
67621|1
68631|1
69641|X
7065X|1
71661|1
72671|1
73681|X
7469X|X
75701|1
76712|1
7772X|1
78731|1
7974X|X
8075X|2
81761|1
82771|1
83781|1
84791|X
85801|X
86811|X
8782X|1
88831|2
89841|X
9085X|2
91861|1
92871|1
93881|X
94891|X
95901|X
9691X|1
9792X|X
9893X|1
99941|2
100
Sheet1


Thank you in advance
</SPAN></SPAN>

Regards,
</SPAN>
Kishan
</SPAN></SPAN>
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG14Sep04
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Temp [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Num [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range("C1,C2:F2,C3:F3")
c = 5
[COLOR="Navy"]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]Select[/COLOR] [COLOR="Navy"]Case[/COLOR] Dn.Row
        [COLOR="Navy"]Case[/COLOR] 1: col = 255
        [COLOR="Navy"]Case[/COLOR] 2: col = 32768
        [COLOR="Navy"]Case[/COLOR] 3: col = 16711680
    [COLOR="Navy"]End[/COLOR] Select
        .Item(Dn.Value) = col
[COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("D6"), Range("D" & Rows.Count).End(xlUp))
    Temp = .Item(Rng(1).Value)
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] .Item(Dn.Value) = Temp [COLOR="Navy"]Then[/COLOR] Num = Num + 1
    [COLOR="Navy"]If[/COLOR] Not .Item(Dn.Value) = Temp [COLOR="Navy"]Then[/COLOR]
        c = c + 1
        Cells(c, "F") = Num: Num = 1
        Cells(c, "F").Interior.Color = Temp
        Cells(c, "F").Font.Color = vbWhite
        Temp = .Item(Dn.Value)
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
        c = c + 1
        Cells(c, "F") = Num: Num = 1
        Cells(c, "F").Interior.Color = Temp
        Cells(c, "F").Font.Color = vbWhite
[COLOR="Navy"]End[/COLOR] With


[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Last edited:
Upvote 0
Try this:-
Code:
[COLOR=navy]Sub[/COLOR] MG14Sep04
[COLOR=navy]Dim[/COLOR] Rng [COLOR=navy]As[/COLOR] Range, Dn [COLOR=navy]As[/COLOR] Range, n [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] c [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Dim[/COLOR] col [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Temp [COLOR=navy]As[/COLOR] [COLOR=navy]Long,[/COLOR] Num [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Range("C1,C2:F2,C3:F3")
c = 5
[COLOR=navy]With[/COLOR] CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
    [COLOR=navy]Select[/COLOR] [COLOR=navy]Case[/COLOR] Dn.Row
        [COLOR=navy]Case[/COLOR] 1: col = 255
        [COLOR=navy]Case[/COLOR] 2: col = 32768
        [COLOR=navy]Case[/COLOR] 3: col = 16711680
    [COLOR=navy]End[/COLOR] Select
        .Item(Dn.Value) = col
[COLOR=navy]Next[/COLOR]
[COLOR=navy]Set[/COLOR] Rng = Range(Range("D6"), Range("D" & Rows.Count).End(xlUp))
    Temp = .Item(Rng(1).Value)
[COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng
    [COLOR=navy]If[/COLOR] .Item(Dn.Value) = Temp [COLOR=navy]Then[/COLOR] Num = Num + 1
    [COLOR=navy]If[/COLOR] Not .Item(Dn.Value) = Temp [COLOR=navy]Then[/COLOR]
        c = c + 1
        Cells(c, "F") = Num: Num = 1
        Cells(c, "F").Interior.Color = Temp
        Cells(c, "F").Font.Color = vbWhite
        Temp = .Item(Dn.Value)
    [COLOR=navy]End[/COLOR] If
[COLOR=navy]Next[/COLOR] Dn
        c = c + 1
        Cells(c, "F") = Num: Num = 1
        Cells(c, "F").Interior.Color = Temp
        Cells(c, "F").Font.Color = vbWhite
[COLOR=navy]End[/COLOR] With


[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
Mick, it worked like magic :mad: as request.</SPAN></SPAN>

Thank you so much
</SPAN></SPAN>

Have a good weekend
</SPAN></SPAN>

Kind Regards,
</SPAN></SPAN>
Kishan :)
</SPAN></SPAN>
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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