Count certain characters in one cell

Flashmus

New Member
Joined
Jan 4, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hey!

Would like some help with counting certain characters in a one cell.

3312221133111

1. Would like to count certain character combination in the string above. The combination I would like to search for is how many times "11" appears.
For me is should be 3 times. First 11 then the 111 contains "11" two times.

"11" = 3 times
"22" = 2 times
"33" = 2 times

2. Would also try to count occurrences of "1". It should count just one time even tho its a single(1), double(11) or tripple(111) and so on.
Here I would like it to count 3 in the string above.

1 = 3 times
2 = 1 time
3 = 2 times
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi

=LET(a,DIVIDI.TESTO(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="11","-"),"1","",1))))
=LET(a,DIVIDI.TESTO(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="22","-"),"2","",1))))
=LET(a,DIVIDI.TESTO(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="33","-"),"3","",1))))
 
Upvote 0
Hi

=LET(a,DIVIDI.TESTO(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="11","-"),"1","",1))))
=LET(a,DIVIDI.TESTO(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="22","-"),"2","",1))))
=LET(a,DIVIDI.TESTO(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="33","-"),"3","",1))))
I doesnt seem to work.
I'm not sure if the DIVIDE.TESTO means TEXTSPLIT in English and I'm trying to translate it to Swedish DELATEXT
I'm getting the value of 1 when I should have the value 3
 
Upvote 0
Hi

=LET(a,TEXTSPLIT(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="11","-"),"1","",1))))
 
Upvote 0
Hi

Vba Mode

VBA Code:
Sub Macro1()
Cells(10, 2).Formula = "=LET(a,TEXTSPLIT(TRIM(F4),,"" ""),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)=""11"",""-""),""1"","""",1))))"
End Sub
 
Upvote 0
Hi

=LET(a,TEXTSPLIT(TRIM(A1),," "),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)="11","-"),"1","",1)))

Hi

Vba Mode

VBA Code:
Sub Macro1()
Cells(10, 2).Formula = "=LET(a,TEXTSPLIT(TRIM(F4),,"" ""),LEN(CONCAT(SUBSTITUTE(FILTER(a,LEFT(a,2)=""11"",""-""),""1"","""",1))))"
End Sub
I cant this too work, im not sure if its a language issue with the textsplit command
 
Upvote 0
Try this

=SUMPRODUCT((MID(A1;SEQUENCE(LEN(A1));1)="1")*(MID(A1&" ";SEQUENCE(LEN(A1))+1;1)<>"1"))
 
Upvote 0
Solution
1. Would like to count certain character combination in the string above. The combination I would like to search for is how many times "11" appears.
For me is should be 3 times. First 11 then the 111 contains "11" two times.
"11" = 3 times
"22" = 2 times
"33" = 2 times
For 1.

=SUMPRODUCT((MID(A1;SEQUENCE(LEN(A1));2)="11")*1)
 
Upvote 0
For 1.

=SUMPRODUCT((MID(A1;SEQUENCE(LEN(A1));2)="11")*1)
It worked! Im trying to get the ="11" part as cell reference instead, but failing. Have 100+ different combinations

=SUMPRODUCT((MID(A1;SEQUENCE(LEN(A1));2)="11")*1)
Any solution?
 
Upvote 0
Change to:

=SUMPRODUCT((MID(A1;SEQUENCE(LEN(A1));2)=C1&"")*1)

Or the format in C1 is TEXT.
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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