Adding numbers within the cell

xoxo

Board Regular
Joined
Mar 29, 2009
Messages
198
Hi all, I am xoxo and new to this forum.

Would like help on how to calculate numbers within a cell. Say, I have these numbers in A1: 01-02-03-04-05 and I want A2 to give me the sum of all the numbers in A1 without the dash. Is it possible?

Thank you very much!
xoxo
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Dave Patton

Well-known Member
Joined
Feb 15, 2002
Messages
5,737
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
try
=SUMPRODUCT(MID(SUBSTITUTE(A1,"-",""),ROW(INDIRECT("1:"&LEN(SUBSTITUTE(A1,"-","")))),1)+0)
 
Upvote 0

xoxo

Board Regular
Joined
Mar 29, 2009
Messages
198
Thank you for the help.

It works for 01-02-03-04-05.

When I apply the formula to a cell with 10-21-24-35-46, how do I go about in doing this? It gave me 28 as the sum, when it should be 136. Thanks.
 
Upvote 0

xoxo

Board Regular
Joined
Mar 29, 2009
Messages
198
Thank you for the quick reply. How do I do text to columns?
 
Upvote 0

Dave Patton

Well-known Member
Joined
Feb 15, 2002
Messages
5,737
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Prior to Excel 2007, look at menu Data | Text to Column

Check for additional information in Excel help.

If your text string is consistent, you can build a formula such as

=SUM((MID(A5,{1,4,7,10,13},2)+0))
 
Upvote 0

xoxo

Board Regular
Joined
Mar 29, 2009
Messages
198
Wow, that works beautifully. Thank you so much for your help!
 
Upvote 0

jeffreybrown

Well-known Member
Joined
Jul 28, 2004
Messages
5,149
As another approach you could use =EVAL(SUBSTITUTE(A5,"-","+")) which would require the numbers to be consistent.
 
Upvote 0

pgc01

MrExcel MVP
Joined
Apr 25, 2006
Messages
19,891
You can use Jeff's approach without the add-in if you define a named formula. It will refer, however, to a cell with a fixed relative offset.

Ex.:

- Select Sheet1!B1

- Define the name:

Name: SumIn
Refers to: =EVALUATE(SUBSTITUTE(Sheet1!A1,"-","+"))

Now you can use this named formula to calculate the cell to the left.

Ex:

C10: 23-1-100-2000
D10: =SumIn

The result in D10 will be 2124.
 
Upvote 0

Forum statistics

Threads
1,190,913
Messages
5,983,539
Members
439,848
Latest member
timmyo

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