Frequency of characters in any order are found in a range

tasty

New Member
Joined
Aug 28, 2020
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
I have been attempting to find a formula that counts the number of times the characters in a cell are found in any of the other strings of letters in a range. (What has stumped me is that I do not want just the exact matches of the characters in the same order, but rather, to count all instances when the characters from the reference cell are found even if they are separated by other characters. In my examples below in column A I have the strings of characters and column B is where I want to display the number of times they appear. My goal is to build a formula that will show me that abce appears twice... once as just abce, and then again as apart of abcde. Then bce appears 3 times in bce, abce, and abcde.
Example 1:
Strings / Count
abce / 2
abcde / 1
ae / 3
bce / 3

I have also formatted my data into strings of 0s and 1s as text to see if going about it this way might make more sense, to no avail. In this case 00101 appears twice, once in 00101, and again in 01111.
Example 2:
Strings / Count
01010 / 2
01111 / 1
00101 / 2
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Welcome to MrExcel!

Interesting problem, how about:

Book1
AB
1abce2
2abcde1
3ae3
4bce3
Sheet2
Cell Formulas
RangeFormula
B1:B4B1=SUM(--(MMULT(--ISNUMBER(FIND(MID(A1,TRANSPOSE(ROW(INDIRECT("1:"&LEN(A1)))),1),$A$1:$A$4)),ROW(INDIRECT("1:"&LEN(A1)))^0)=LEN(A1)))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Eric handed you what you asked for.
Another way (not what you asked for!)
Code:
Sub Maybe()
Dim j As Long, a As String, c As Range, i As Long, x As Long, xx As Long
    For j = 1 To Cells(Rows.Count, 1).End(xlUp).Row
    a = Cells(j, 1).Value
        For Each c In Range("A1:A4")
            For i = 1 To Len(a)
                If InStr(c, Mid(a, i, 1)) <> 0 Then x = x + 1
            Next i
                If x = Len(a) Then xx = xx + 1
                    x = 0
                Next c
            Cells(j, 1).Offset(, 1).Value = xx
        x = 0
    xx = 0
    Next j
End Sub
 
Upvote 0
Thanks for the welcome and your solution! This absolutely solved what I was looking for, and I wish I had asked for help much sooner.

Would it be possible to add one more layer to this? I realize that the formula tells me how many times this pattern appears, but the way my data is provided to me it groups all of the same exact strings of patterns and counts how many times it occurred in a Column C. In the demo example abce shows up, in this case 400 times as a unique pattern, could we modify your formula in B to sum the volume amounts instead of count the instances that the pattern appears? Below it would 600 times (400 as abce, and 200 as abcde)
Strings / Count / Volume
abce / 600 / 400
abcde / 200 / 200
ae / 1200 / 500
bce / 700 / 100
 
Upvote 0
That's just a minor change:

Book1
ABC
1abce600400
2abcde200200
3ae1100500
4bce700100
Sheet2
Cell Formulas
RangeFormula
B1:B4B1=SUM((MMULT(--ISNUMBER(FIND(MID(A1,TRANSPOSE(ROW(INDIRECT("1:"&LEN(A1)))),1),$A$1:$A$4)),ROW(INDIRECT("1:"&LEN(A1)))^0)=LEN(A1))*$C$1:$C$4)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,039
Messages
6,122,802
Members
449,095
Latest member
m_smith_solihull

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