# Adding numbers in between slashes

##### Well-known Member
Hi Guys,

Is there a formula that can add numbers separated by slashes in a cell? So for example I have 0/2/1/0/3, the desired result is 6.

Thanks

#### kbrummert

##### New Member
If you are ok using a custom function...

Code:
``````Function Eval(Ref As String)

Dim sbs As String

sbs = WorksheetFunction.Substitute(Ref, "/", "+")
Eval = Evaluate(sbs)

End Function``````

##### Well-known Member
That's wonderful. That will be one option. But I prefer to do it with a formula. So I will wait for another guru to give another answer before I use this one.

##### Well-known Member
I am thinking of changing that VB script to formula. Something like:
Code:
``=SUM(SUBSTITUTE(A1,"/",","))``
with ctrl+shift+enter
It gives an error.
But the solution must along the similar lines.

#### Tetra201

##### MrExcel MVP
Try

=SUMPRODUCT(--MID(SUBSTITUTE(A1,"/",""),ROW(INDEX(A:A,1):INDEX(A:A,LEN(SUBSTITUTE(A1,"/","")))),1))

##### Well-known Member
=SUMPRODUCT(--MID(SUBSTITUTE(A1,"/",""),ROW(INDEX(A:A,1):INDEX(A:A,LEN(SUBSTITUTE(A1,"/","")))),1))
Beautiful.
Works perfect.
Thanks a lot.

##### Well-known Member
=SUMPRODUCT(--MID(SUBSTITUTE(A1,"/",""),ROW(INDEX(A:A,1):INDEX(A:A,LEN(SUBSTITUTE(A1,"/","")))),1))
This wouldn't work if there was a double digit number, will it? Like 0/11/2/0/3, the answer should be 16 but the formula gives 7.

#### Tetra201

##### MrExcel MVP
In this case, an UDF would be, probably, the easiest approach:
Code:
``````Function SumNum(s As String) As Double
SumNum = Evaluate(Replace(s, "/", "+"))
End Function``````

#### Dave Patton

##### Well-known Member
<b>Excel 2010</b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style=";">0/2/1/0/3</td><td style="text-align: right;;">6</td><td style="text-align: right;;">6</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">2</td><td style=";">0/21/0/3</td><td style="text-align: right;;">24</td><td style="text-align: right;;">24</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">3</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr></tbody></table><p style="width:1.2em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">3d</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">B1</th><td style="text-align:left">=Calc</td></tr><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">C1</th><td style="text-align:left">=Eval(<font color="Blue">A1</font>)</td></tr></tbody></table></td></tr></table><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: rgb(255,255,255)" ><tr><td style="padding:6px" ><b>Workbook Defined Names</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: rgb(255,255,255);border-collapse: collapse; border-color: rgb(187,187,187)"><thead><tr style=" background-color: rgb(218,231,245);color: rgb(22,17,32)"><th width="10px">Name</th><th style="text-align:left">Refers To</th></tr></thead><tbody><tr><th width="10px" style=" background-color: rgb(218,231,245);color: rgb(22,17,32)">Calc</th><td style="text-align:left">=EVALUATE(<font color="Blue">SUBSTITUTE(<font color="Red">!B3,"/","+"</font>)</font>)</td></tr></tbody></table></td></tr></table><br />

Use a Named range
Select cell B1
With Name Manager
New I used the name "Calc".
Refers to: =EVALUATE(SUBSTITUTE(!A1,"/","+"))

This obviously is equivalent to the UDF Eval.

Thanks Tetra201

1,081,849
Messages
5,361,673
Members
400,644
Latest member
ndroger1

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...