Counting Occurrences of a Character for Specific Rows of a Dataset

SteveQ

New Member
Joined
Dec 24, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Looking for a solution to count the number of occurences of a specific character in a dataset BUT only for specific rows.
I've used the following formula for counting the number of occurences of a specific character: =SUM(LEN(range)-LEN(SUBSTITUTE(range,"text","")))/LEN("text"). My question is how do I adjust that formula or use another formula to count those characters ONLY for specific rows. For example:
In the following dataset, the formula above counts the total number of occurences of "c" in columns B and C and yields 3 occurences.
What formula will count the total number of occurences of "c" asscociated with BOB (there are 2 occurences)?

1703462741591.png
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Try...

VBA Code:
=SUM(IF(A1:A4="BOB",LEN(B1:C4)-LEN(SUBSTITUTE(B1:C4,"c","")))/LEN("c"))

or

VBA Code:
=LET(data,FILTER(A1:C4,A1:A4="BOB",0),SUM(LEN(data)-LEN(SUBSTITUTE(data,"c","")))/LEN("c"))

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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