I have a few questions regarding pattern matching in excel. This is a snippet of a 16x16 cells (some cells are empty):
<table border="0" cellpadding="0" cellspacing="0" width="256"><colgroup><col style="width:48pt" span="4" width="64"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;width:48pt" height="20" width="64">B13N</td> <td class="xl64" style="width:48pt" width="64">B11N</td> <td class="xl63" style="width:48pt" width="64">
</td> <td class="xl64" style="width:48pt" width="64">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;border-top:none" height="20">B10S</td> <td class="xl64" style="border-top:none">
</td> <td class="xl63" style="border-top:none">
</td> <td class="xl64" style="border-top:none">B09N</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;border-top:none" height="20">PU/R04</td> <td class="xl64" style="border-top:none">R07</td> <td class="xl63" style="border-top:none">D1/PY07</td> <td class="xl66" style="border-top:none">R04/TD</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl69" style="height:15.0pt;border-top:none" height="20">
</td> <td class="xl70" style="border-top:none">
</td> <td class="xl71" style="border-top:none">
</td> <td class="xl70" style="border-top:none">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt;border-top:none" height="20">B07K</td> <td class="xl68" style="border-top:none">B08N/B13K</td> <td class="xl67" style="border-top:none">B08N/B06S</td> <td class="xl68" style="border-top:none">
</td> </tr> </tbody></table>
What I want to count each occurance of a pattern, such as "B??N" and sum that in a cell on the same row it is found. The problem is that when there are multiple matches in one cell COUNTIF() only counts the first match:
=COUNTIF(INDIRECT("AV"&ROW()&":BK"&ROW()),"*B??N*")
If I use (morefunc) MCONCAT to put it all in a string the same problem arise, only worse; I get just one hit per string. I used "/" as a separator in hopes that there would be a function where it would be useful.
Another problem I have is extracting the numbers from some of these patterns and manipulating them.
The only way I've gotten it to work is to copy 16 formulas refering to the 16 different cells one at a time per summary cell (for R??, PY?? and D?) to extract the numbers and add them up. This however works, but is noticibly intensive. I do these 16x fomulas for each of these, per row. At this time there are 16 of these 16x16 arrays they work on, and many more to come.
This is an example of the formula:
=IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AV"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AW"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AX"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AY"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AZ"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BA"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BB"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BC"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BD"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BE"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BF"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BG"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BH"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BI"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BJ"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BK"&ROW())),"R\d{2}"),2)),0)
These formulas also pose the problem of inserting more colums between the "data" part of the sheet and the summary coulmns.
<table border="0" cellpadding="0" cellspacing="0" width="256"><colgroup><col style="width:48pt" span="4" width="64"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;width:48pt" height="20" width="64">B13N</td> <td class="xl64" style="width:48pt" width="64">B11N</td> <td class="xl63" style="width:48pt" width="64">
</td> <td class="xl64" style="width:48pt" width="64">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;border-top:none" height="20">B10S</td> <td class="xl64" style="border-top:none">
</td> <td class="xl63" style="border-top:none">
</td> <td class="xl64" style="border-top:none">B09N</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;border-top:none" height="20">PU/R04</td> <td class="xl64" style="border-top:none">R07</td> <td class="xl63" style="border-top:none">D1/PY07</td> <td class="xl66" style="border-top:none">R04/TD</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl69" style="height:15.0pt;border-top:none" height="20">
</td> <td class="xl70" style="border-top:none">
</td> <td class="xl71" style="border-top:none">
</td> <td class="xl70" style="border-top:none">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl67" style="height:15.0pt;border-top:none" height="20">B07K</td> <td class="xl68" style="border-top:none">B08N/B13K</td> <td class="xl67" style="border-top:none">B08N/B06S</td> <td class="xl68" style="border-top:none">
</td> </tr> </tbody></table>
What I want to count each occurance of a pattern, such as "B??N" and sum that in a cell on the same row it is found. The problem is that when there are multiple matches in one cell COUNTIF() only counts the first match:
=COUNTIF(INDIRECT("AV"&ROW()&":BK"&ROW()),"*B??N*")
If I use (morefunc) MCONCAT to put it all in a string the same problem arise, only worse; I get just one hit per string. I used "/" as a separator in hopes that there would be a function where it would be useful.
Another problem I have is extracting the numbers from some of these patterns and manipulating them.
The only way I've gotten it to work is to copy 16 formulas refering to the 16 different cells one at a time per summary cell (for R??, PY?? and D?) to extract the numbers and add them up. This however works, but is noticibly intensive. I do these 16x fomulas for each of these, per row. At this time there are 16 of these 16x16 arrays they work on, and many more to come.
This is an example of the formula:
=IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AV"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AW"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AX"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AY"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("AZ"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BA"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BB"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BC"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BD"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BE"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BF"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BG"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BH"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BI"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BJ"&ROW())),"R\d{2}"),2)),0)+IFERROR(VALUE(RIGHT(REGEX.MID(MCONCAT(INDIRECT("BK"&ROW())),"R\d{2}"),2)),0)
These formulas also pose the problem of inserting more colums between the "data" part of the sheet and the summary coulmns.
Last edited: