Adding multiple numbers in the same cell

bmwbuyer2007

Board Regular
Joined
Jul 19, 2007
Messages
82
Hi all,

Just wondering if it is possible to add numbers which are in the same cell, seperated by commas, for example

A B
1 Person 1 10, 10, 15
2 Person 2 10
3 Person 3 10, 10
4 Total 65

I know I could just put each number in a different cell, but for some reason the powers that be don't want to do this :)

Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Hi,Give this a try,
Numbers in column "B"
Code:
Dim cl As Range, oSum, s As Integer, Tot As Double
For Each cl In Range(Range("b1"), Range("b" & Rows.Count).End(xlUp))
oSum = Split(cl, ",")
If InStr(cl, ",") > 0 Then
   For s = 0 To UBound(oSum)
        Tot = Tot + oSum(s)
      Next s
    Else
   Tot = Tot + cl
End If
Next cl
MsgBox Tot
Regards Mick
 
Upvote 0

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,892
Hi bmwbuyer2007

You can use this UDF:

Code:
Function SumComma(s As String)
    SumComma = Evaluate(Replace(s, ",", "+"))
End Function

Use it as any other worksheet function, like:

=SumComma(B1)
 
Upvote 0

Forum statistics

Threads
1,191,226
Messages
5,985,373
Members
439,961
Latest member
drose1105

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
Top