extract all numbers (double digit) in excel and sum

sosolid4u09

New Member
Joined
Feb 8, 2018
Messages
6
Hi everyone,

I have a bit of a complex problem.

I have a column like the following;

Training: 7, Fighting: 12, Speed: 3

I need a formula that sums together 7+12+3 automatically.

Now I got a solution where i extract all the digits in that cell and sum. But that ends up giving me 7+1+2+3 which is obviously not correct.

Does anyone have an idea?

Thanks
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Welcome to Mr Excel Forum

Maybe something like this

A
B
C
1
Values​
Result​
2
Training: 7​
22​
3
Fighting: 12​
4
Speed: 3​

Formula in C2
=SUMPRODUCT(--MID(A2:A4,SEARCH(":",A2:A4)+1,100))

M.
 
Upvote 0
Welcome to Mr Excel Forum

Maybe something like this

A
B
C
1
Values​
Result​
2
Training: 7​
22​
3
Fighting: 12​
4
Speed: 3​

<tbody>
</tbody>


Formula in C2
=SUMPRODUCT(--MID(A2:A4,SEARCH(":",A2:A4)+1,100))

M.

thanks for the response

But the

Training: 7, Fighting: 12, Speed: 3

Is in one row, not in columns

 
Upvote 0
Is there are always exactly 3 "skills" whose values you want to add up or could the number of "skills" vary?

Skill names don't vary.

Always three skills.

One DQ issue though is that there are times people leave the value blank. i.e.
Training: , Fighting: 12, Speed:
Training: 0, Fighting: , Speed: 3

 
Upvote 0
Can you make use of a VBA solution, namely, a UDF (user defined function)? If so...
Code:
Function SkillSum(S As String) As Double
  Dim V As Variant
  For Each V In Split(S, ":")
    SkillSum = SkillSum + Val(V)
  Next
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use SkillSum just like it was a built-in Excel function. For example,

=SkillSum(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.
 
Upvote 0
Can you make use of a VBA solution, namely, a UDF (user defined function)? If so...
Code:
Function SkillSum(S As String) As Double
  Dim V As Variant
  For Each V In Split(S, ":")
    SkillSum = SkillSum + Val(V)
  Next
End Function

HOW TO INSTALL UDFs
------------------------------------
If you are new to UDFs, they are easy to install and use. To install it, simply press ALT+F11 to go into the VB editor and, once there, click Insert/Module on its menu bar, then copy/paste the above code into the code window that just opened up. That's it.... you are done. You can now use SkillSum just like it was a built-in Excel function. For example,

=SkillSum(A1)

If you are using XL2007 or above, make sure you save your file as an "Excel Macro-Enabled Workbook (*.xlsm) and answer the "do you want to enable macros" question as "yes" or "OK" (depending on the button label for your version of Excel) the next time you open your workbook.

Outstanding good man.

Thanks a lot
 
Upvote 0
I think an User Defined Function (UDF) should be the proper solution.

Anyway, this array formula worked for your examples


A
B
1
Text​
Result​
2
Training: 7, Fighting: 12, Speed:3​
22​
3
Training: , Fighting: 12, Speed:​
12​
4
Training: 0, Fighting: , Speed: 3​
3​

Array Formula in B2 copied down
=SUM(IFERROR(0+TRIM(MID(SUBSTITUTE(SUBSTITUTE(":"&A2,":",REPT(" ",500)),",",REPT(" ",500)),ROW(A$1:A$100)*500,500)),0))

confirmed with Ctrl+Shift+Enter, not just Enter

M.
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

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