Counting multiple letters in cells

allunderme

New Member
Joined
May 16, 2013
Messages
20
Hi,

I have a large list of policy numbers with different letters held within (eg MT/1/PD/101271A, 07BV/17345057, BL/1/ /635663A, MALZ32741) all have different formats and some contain /'s. They have all been manually added so each line differs slightly. I have a list of letter prefixes i wish to identify (BV, MT, MALZ etc) there are 11 in total.

Does anyone know how i can count these letter formats from this list of policy numbers?

Im scratching my head so any help would be really appreciated.

Allun
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi Allun

To count for ex. the ones that start with "BV", try:

=COUNTIF(A2:A1000,"BV*")
 
Upvote 0
... you can also refer to a cell.

Write "BV" in B1 and use:

=COUNTIF(A2:A1000,B1&"*")
 
Upvote 0
HI Allun
I would create a matrix, like below, the reason are as follows, depending on your list, we don't know if you have duplicates i.e. policy number which will return a true value (contain more than one of you keys), in my column E, it will tell you if their are found more than once, you would need to check these manually, if only found once, you could just count as requested in the small 2 column list below

Policy Numbers BVMTMALZCount of none
MT/1/PD/101271A=IFERROR(SEARCH($B$1,A2),"")=IFERROR(SEARCH($C$1,A2,1),"")=IFERROR(FIND($D$1,A2),"")=COUNT(B2:D2)
07BV/17345057=IFERROR(SEARCH($B$1,A3),"")=IFERROR(SEARCH($C$1,A3,1),"")=IFERROR(FIND($D$1,A3),"")=COUNT(B3:D3)
BL/1/ /635663A=IFERROR(SEARCH($B$1,A4),"")=IFERROR(SEARCH($C$1,A4,1),"")=IFERROR(FIND($D$1,A4),"")=COUNT(B4:D4)
MALZ32741=IFERROR(SEARCH($B$1,A5),"")=IFERROR(SEARCH($C$1,A5,1),"")=IFERROR(FIND($D$1,A5),"")=COUNT(B5:D5)
MT/1/PD/101271A=IFERROR(SEARCH($B$1,A6),"")=IFERROR(SEARCH($C$1,A6,1),"")=IFERROR(FIND($D$1,A6),"")=COUNT(B6:D6)
BV=COUNT(B1:B7)
MT=COUNT(C1:C7)
MALZ=COUNT(D1:D7)

<colgroup><col style="mso-width-source:userset;mso-width-alt:4790;width:197pt" width="262"> <col style="mso-width-source:userset;mso-width-alt:3730;width:153pt" width="204"> <col style="mso-width-source:userset;mso-width-alt:3949;width:162pt" width="216"> <col style="mso-width-source:userset;mso-width-alt:3437;width:141pt" width="188"> <col style="mso-width-source:userset;mso-width-alt:1938;width:80pt" width="106"> </colgroup><tbody>
</tbody>
Regards
Pup

You can just copy and past the data above into a new spreadsheet, so you can see how it works, please get back to me if this doesn't resolve your issue

<colgroup><col style="mso-width-source:userset;mso-width-alt:4790;width:197pt" width="262"> <col style="mso-width-source:userset;mso-width-alt:3730;width:153pt" width="204"> <col style="mso-width-source:userset;mso-width-alt:3949;width:162pt" width="216"> <col style="mso-width-source:userset;mso-width-alt:3437;width:141pt" width="188"> <col style="mso-width-source:userset;mso-width-alt:1938;width:80pt" width="106"> </colgroup><tbody>
</tbody>

<colgroup><col style="mso-width-source:userset;mso-width-alt:9508;width:195pt" width="260"> <col style="mso-width-source:userset;mso-width-alt:877;width:18pt" width="24"> <col style="mso-width-source:userset;mso-width-alt:950;width:20pt" width="26"> <col style="mso-width-source:userset;mso-width-alt:1499;width:31pt" width="41"> <col style="mso-width-source:userset;mso-width-alt:1060;width:22pt" width="29"> <col style="mso-width-source:userset;mso-width-alt:3510;width:72pt" width="96"> <col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:1499;width:31pt" width="41"> <col style="mso-width-source:userset;mso-width-alt:512;width:11pt" width="14"> </colgroup><tbody>
</tbody>
 
Upvote 0
thank you but do you know how i would count the lines containing "BV" where this is not at the begining of the cell?

These letter codes are all in different locations within the cell
 
Upvote 0
If it is not at the beginning of the cell:

=COUNTIF(A2:A1000,"*BV*")

This will find BV anywhere in the text of the cells.
 
Upvote 0
allunderme,

How about:


Excel 2007
ABCDEFGHIJKLMNO
1Policy Numbers*BV**MT**MALZ**4**5**6**7**8**9**10**11*CodesTotals
2MT/1/PD/101271A01000010010BV1
307BV/1734505710011010000MT2
4BL/1/ /635663A00001100000MALZ1
5MALZ327410011001000042
6MT/1/PD/101271A0100001001052
761
874
980
1090
11102
12110
1315
14
Sheet1
Cell Formulas
RangeFormula
B2=COUNTIF($A2,B$1)
O2=SUM($B:$B)
O3=SUM($C:$C)
O4=SUM(D:D)
O5=SUM(E:E)
O6=SUM(F:F)
O7=SUM(G:G)
O8=SUM(H:H)
O9=SUM(I:I)
O10=SUM(J:J)
O11=SUM(K:K)
O12=SUM(L:L)
O13=SUM(O2:O12)



Add the additional codes in range E1:L1, with leading and trailing * characters.

And, add the additional codes in range N5:N12 without the leading and trailing * characters.


The formula in cell B2, copied to range B2:L6:

=COUNTIF($A2,B$1)
 
Upvote 0
Hi,

I have a large list of policy numbers with different letters held within (eg MT/1/PD/101271A, 07BV/17345057, BL/1/ /635663A, MALZ32741) all have different formats and some contain /'s. They have all been manually added so each line differs slightly. I have a list of letter prefixes i wish to identify (BV, MT, MALZ etc) there are 11 in total.

Does anyone know how i can count these letter formats from this list of policy numbers?

Im scratching my head so any help would be really appreciated.

Allun

Given a sample like:
MT/1/PD/101271A
07BV/17345057
BL/1/ /635663A
MALZ32741

<tbody>
</tbody>

what is the expected outcome?
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,638
Members
449,093
Latest member
Ahmad123098

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