[Adding this as an answer because I don't have a high enough Reputation score to post comments]
I know this is an old question, and not sure if it's ok to add on a variation, but here goes anyway:
I have a very similar use case, except that the values I'm trying to match may have numbers at the end, like A1, A2, CR3, etc. I want them to be added up such that all A* are counted together, all CR* are counted together, etc.
I'm using the solution provided by @VBasic2008 , and I tried adding the * in the Code list, but it doesn't work. How do I enable this for wildcards? Thanks in advance!