Forum menu
Excel help: count m...
 

Excel help: count multiple occurences of a text string in a single cell

 Pook
Posts: 12698
Full Member
Topic starter
 

Is there a way to do this?

We have a team planning sheet and in row 4, annual leave and our of offices are shown. 

Everyone adds their own.

 

Is there a way to count the occurrences of "OOO" and "A/L" to give an indication of team capacity? 

 

Changing the sheet set up is not an option.

Using a proper tool is not an option.


 
Posted : 30/06/2025 8:32 am
Posts: 245
Full Member
 

=SUM(COUNTIF(A1:A4,{“A/L”,”OOO”}))

Change the range to whatever obviously 


 
Posted : 30/06/2025 8:44 am
Posts: 738
Free Member
 

The SEARCH function will probably be the one here.

 

You can use it in such as way that it will search for the second occurrence starting at the position of the previous one, plus one.

 

Then some kind of logic on top to display a 1 for the first find, a 1 for any subsequent finds then total it up.

 

You can build in different cells and bring together, but SEARCH is a bit tricky to clean up into one cell when you use it as above.


 
Posted : 30/06/2025 8:46 am
Posts: 738
Free Member
 

I use SEARCH a lot as people try (nicely) to pack loads of data fields into one 'cell' on accounting software.

 

Take the below text string in cell A1.

 

Dave/would/like/to/meet/today

 

It is clear that / shows a boundary but it is internal to the cell.

 

In cell C1 you type =SEARCH("/",$A1,B1+1)

This will bring back the position (5) of the first occurrence of /.

If you copy that across to D1, E1 etc it will bring back the position of each subsequent occurrence.

 

You can then build off of this info to get what you need. I use it often instead of text to columns as text to columns actually changes the source data - something I was taught not to do if you want your methodology to be auditable.

 

Good luck, there's a way around most things in Excel.


 
Posted : 30/06/2025 8:53 am
Posts: 78370
Full Member
 

What happens when they're off sick?


 
Posted : 30/06/2025 8:59 am
Posts: 10954
Full Member
 

Something like

= (LEN(A4) - LEN(SUBSTITUTE(A4, "OOO", ""))) /3

Should give the number of "OOO" s in A4.


 
Posted : 30/06/2025 9:05 am
Posts: 738
Free Member
 

Something like

 

= (LEN(A4) - LEN(SUBSTITUTE(A4, "OOO", ""))) /3

 

Should give the number of "OOO" s in A4.

Ooh, I like that!

Presumably if one of the codes you are looking for is a text string of 4 characters, you adjust the dividing by three to dividing by four?

 

Like it, though. Neat.

 


 
Posted : 30/06/2025 9:51 am
Posts: 10954
Full Member
 

Yes you'd nest to divide by the number of characters in the search string. Probably also worth changing to
LEN(SUBSTITUTE (UPPER(A4),...

to include instances of OoO or ooo


 
Posted : 30/06/2025 10:14 am