Counting groups

paulopinto

New Member
Joined
Sep 20, 2018
Messages
1
I need to count the occurrences of groups of symbols in a column as follows:


Symbols
XOOX
XXOX
OXXX
XOXX
XXXO
GroupsOccurrences
O1201
OO0010
OOO0000
OOOO0000
X0100
XX2100
XXX0010
XXXX0001

<tbody>
</tbody>

Please, how can I do that?
Thanks.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try this:-
Symbols start "A2"
Groups symbols start "G2".
Results start "H2"

Code:
[COLOR=navy]Sub[/COLOR] MG21Sep08
[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] ac [COLOR=navy]As[/COLOR] [COLOR=navy]Long[/COLOR]
[COLOR=navy]Dim[/COLOR] Rng1 [COLOR=navy]As[/COLOR] Range, Temp [COLOR=navy]As[/COLOR] [COLOR=navy]String,[/COLOR] nStr [COLOR=navy]As[/COLOR] [COLOR=navy]String,[/COLOR] Sp [COLOR=navy]As[/COLOR] Variant
[COLOR=navy]Set[/COLOR] Rng = Range("A2", Range("A" & Rows.Count).End(xlUp))
[COLOR=navy]Set[/COLOR] Rng1 = Range("G2", Range("G" & Rows.Count).End(xlUp))
Rng1.Offset(, 1).Resize(, 4).Value = 0

[COLOR=navy]For[/COLOR] ac = 0 To 3
  nStr = ""
  [COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng.Offset(, ac)
        [COLOR=navy]If[/COLOR] Dn.Address = Rng.Offset(, ac)(1).Address [COLOR=navy]Then[/COLOR]
            nStr = Dn
       [COLOR=navy]Else[/COLOR]
            nStr = nStr & IIf(Dn.Value = Temp, "", ",") & Dn.Value
        [COLOR=navy]End[/COLOR] If
            Temp = Dn.Value
    [COLOR=navy]Next[/COLOR] Dn
        Sp = Split(nStr, ",")
        [COLOR=navy]For[/COLOR] n = 0 To UBound(Sp)
            [COLOR=navy]For[/COLOR] [COLOR=navy]Each[/COLOR] Dn [COLOR=navy]In[/COLOR] Rng1
                [COLOR=navy]If[/COLOR] Dn = Sp(n) [COLOR=navy]Then[/COLOR]
                    Dn.Offset(, ac + 1) = Dn.Offset(, ac + 1) + 1
                    [COLOR=navy]Exit[/COLOR] For
                [COLOR=navy]End[/COLOR] If
            [COLOR=navy]Next[/COLOR] Dn
        [COLOR=navy]Next[/COLOR] n
[COLOR=navy]Next[/COLOR] ac
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,978
Messages
6,128,065
Members
449,417
Latest member
flovalflyer

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