sum in a range of cells that contain letters and numbers

anaop

New Member
Joined
Mar 28, 2014
Messages
2
Hello everyone,

I need to sum all the numerical values (the numbers before the letter) in column A based on what letter they have. So, the result for "a" would be 3.5, "b" would be 3 etc. (as below in red)

Notes and restrictions: The only possible numerical values are :1 or 2 or 0.5. Letters can be : a, b, c, x, z. This column cannot be broken into 2 columns, one that stores letters and one that stores numbers, it all has to be in the same column.

The best I could come up with for now is something along the lines of:

=SUMPRODUCT((RIGHT(B2:B25,1)="a"), VALUE((LEFT(B2:B25,LEN(B2:B25)-1)))) - which isn't working, so this is why I need help.

What I am trying to do in the statement above is: for all the cells within Col B where the value ends with the letter "a", then sum up the (length -1) left corresponding characters (as 0.5 and 1 have varying lengths), while turning them into numbers, as they are perceived as text values.

I am not sure if I am even on the right track or my thinking might need to be revamped completely. Any help would be greatly appreciated.




[TABLE="width: 325"]
<tbody>[TR]
[TD][/TD]
[TD="align: right"]Col B[/TD]
[/TR]
[TR]
[TD]Client1
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client2[/TD]
[TD]1a
[/TD]
[/TR]
[TR]
[TD]Client3[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client4[/TD]
[TD]1b[/TD]
[/TR]
[TR]
[TD]Client5[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client6[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client7[/TD]
[TD]1c[/TD]
[/TR]
[TR]
[TD]Client8[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client9[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client10[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client11[/TD]
[TD]0.5a[/TD]
[/TR]
[TR]
[TD]Client12[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client13[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client14[/TD]
[TD]2b[/TD]
[/TR]
[TR]
[TD]Client15[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client16[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client17[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client18[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client19[/TD]
[TD]2a[/TD]
[/TR]
[TR]
[TD]Client20[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client21[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Client22[/TD]
[TD]0.5c[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]a
[/TD]
[TD="align: right"]3.5[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]1.5[/TD]
[/TR]
</tbody>[/TABLE]
 
Hi,

Not sure I understand. Just taking a single cell, 0.5a say, what would be the result here? 0.5 * 3.5 = 1.75?

Regards
 
Upvote 0
anaop,

Maybe....

Excel 2007
AB
1Client1
2Client21a
3Client3
4Client41b
5Client5
6Client6
7Client71c
8Client8
9Client9
10Client10
11Client110.5a
12Client12
13Client13
14Client142b
15Client15
16Client16
17Client17
18Client18
19Client192a
20Client20
21Client21
22Client220.5c
23
24a3.5
25b3
26c1.5
Sheet1
Cell Formulas
RangeFormula
B24{=SUMPRODUCT((RIGHT($B$1:$B$22,1)=A24)*IFERROR(1*LEFT($B$1:$B$22,LEN($B$1:$B$22)-1),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.


Hope that helps.
 
Upvote 0
Or, again, array formula**:

=SUM(IFERROR(0+SUBSTITUTE(B2:B25,{"a","b","c"},""),0)*{3.5,3,1.5})

Regards
 
Upvote 0
=+SUM(IFERROR(LEFT(B1:B4,LEN(B1:B4)-1),0)*1)*IFERROR((RIGHT(B1:B4,1)="a"),0))

Enter this formula with CTRL+SHIFT+ENTER.

Replace "B1:B4" to whatever array length you need.

Cheers
 
Last edited:
Upvote 0
Snakehips - thank you so much for that - it works!!! Brilliant - thank you for nicely formatting the post (this has been my first ever post on a forum like this) and for the ctrl+shift+enter advice. I have no idea what this does as I've never heard of it before, but thank you so much. Greatly appreciated.
 
Upvote 0

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