Adding columns containing numbers with dashes

R

Randi

I have several columns (formatted as text) containing numbers with
dashes, i.e.,

20-1
15-2
30-4
05-3

Is there a way to add up the numbers separately in the column, i.e,
one total for the 20, 15, 20, 05 and one total for the 1, 2, 4, 3. If unable
to add both is it possible to add up just the numbers to the left of the
dash? Thanks.
 
M

MartinW

Hi Randi,

Assuming your data is in A1:A4
In B1 put =SUM(LEFT(A1:A4,2)*1)
and in C1 put =SUM(RIGHT(A1:A4,1)*1)
Both formulae are array formulas so must be committed with
Ctrl+Shift+Enter and not just enter

HTH
Martin
 
E

Elkar

These formulas should work:

For numbers to the left of the -:
=SUMPRODUCT(--(LEFT(A1:A10,FIND("-",A1:A10)-1)))

For numbers to the right of the -:
=SUMPRODUCT(--(MID(A1:A10,FIND("-",A1:A10)+1,99)))

Adjust the range A1:A10 to meet your needs.

HTH,
Elkar
 
R

Randi

Thank you - that works - but now I need something different. How can I
change that formula to multiple the number to the left of the dash by the
number to the right of the dash, i.e., 40-2 = 80 and thenadd up the totals?
thanks
 
M

MartinW

Hi Randi,

This will work for your simplified example
=SUMPRODUCT(--(LEFT(A1:A4,2)*(--(RIGHT(A1:A4,1)))))

However I think it may be better to look at separating your data
with text to columns and then working from there.

HTH
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top