To solve this with formulae you need to know:
- The starting character
- The ending character
- The length of your Call ID
Finding all possible Call IDs

Let B1
be your number string and B2
be the call ID (or pattern) you are looking for. In B5
enter the formula =MID($B$2,1,1)
to find the starting character you are looking for. In B6
enter =RIGHT($B$2,1)
for the end character. In B7
enter =LEN($B$2)
for the length of the call ID.
In Column A we'll enter the position of every starting character. The first formula will be a simple Find()
formula in B10
as =FIND($B$5,$B$1,1)
. To find the other starting characters start the Find()
at the location after the last starting character: =FIND($B$5,$B$1,$A10+1)
in B11
. Copy this down the column a few dozen times (or more).
In Column B we'll see if the next X characters (where X is the length of the Call ID) meets the criteria for a Call ID:
=IF(MID($B$1,$A10+($B$7-1),1)=$B$6,TRUE,FALSE)
The MID($B$1,$A10+($B$7-1),1)=$B$6
checks if the character at the end of the character at the end of this possible Call ID is the end character we're looking for. $A10+($B$7)
calculates the position of the possible Call ID and $B$6
is the end character.
In Column C we can return the actual Call ID if there is a match. This isn't necessary to find the count, but will be useful later. Simply check if the value in Column B is True and, if yes, return the calculated string: =IF(B10,MID($B$1,$A10,$B$7),"")
.
To actually count the number of valid Call IDs, do a CountIf()
of the Call ID column to check for the number of True
values: =IF(B10,MID($B$1,$A10,$B$7),"")
.
If you don't want all the #Values!
just wrap everything in IFERROR(,"")
formulas.
Finding all consecutive Call IDs

However , some of these Call IDs overlap. Operating on the assumption that Call IDs cannot overlap, we simply have to start our search after the end character of a found ID, not the start. Insert an "Ending Position" column in Column B with the formulae: =$A10+($C$7-1)
, starting in B11
. Alter A11
to =FIND($C$5,$C$1,$B10+1)
and copy down. Don't change A10
as this finds the first starting position and is not depending on anything but the original text.
Which ones are valid?
I don't know, that depends on other criteria for your Call IDs. If you receive them consecutively, then the second method is best and the other possible ones found are by coincidence. If not, then you'll have to apply some other validation criteria to the first method, hence why we identified each ID.