How can I sum a range that some cells have text and numbers.

TomA

New Member
Joined
Oct 3, 2004
Messages
26
How can I sum all the values in a range of cells where the cells contain either a number or text and a number. Please note the following example?

C17=9
D17=4
E17=8TD
F17=3TP
G17=7

I want the total of 31 but excel will ignore the cells with text.

Can you help me please?
Thanks
 
=SUMPRODUCT((0&SUBSTITUTE(SUBSTITUTE(C17:G17,"TD",""),"TP",""))+0)

This works! Thanks Barry Houdini!

Thanks to all who have helped.
 
Upvote 0

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
=SUM(IF(C17:W17<>"",SUBSTITUTE(SUBSTITUTE(C17:W17,"TD",""),"TP","")+0))

For what it's worth, the above formula needs to be confirmed with CONTROL+SHIFT+ENTER...
 
Upvote 0
Thanks for all your help.

=SUMPRODUCT((0&SUBSTITUTE(SUBSTITUTE(C17:G17,"TD",""),"TP",""))+0)

Well I have another problem. Although the above formula posted does work and solves one problem I have now encountered an additional problem later in the worksheet I am putting together. I am hoping you can help. I need to now be able have the text "I" and "INT" included with "TD" & "TP". The only difference is that "I" and "INT" will be alone in each cell. No number will be with I or INT. The above formula works but only if there are numbers and text. It produces a ### error when a cell contains just text.
Can you help please?
Thanks.
TOMA
 
Upvote 0
Try...

=SUM(IF(C17:G17<>"",IF(ISNA(MATCH(C17:G17,{"I","INT"},0)),SUBSTITUTE(SUBSTITUTE(C17:G17,"TD",""),"TP","")+0)))

...confirmed with CONTROL+SHIFT+ENTER, not just ENTER.

Hope this helps!
 
Upvote 0
Or, extending my suggestion above

=SUMPRODUCT((0&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C17:G17,"TD",""),"TP",""),"INT",""),"I",""))+0)
 
Upvote 0
Hi

This is a bigger formula but it doen't depend on specific suffixes.
This formula considers the codes composed of some digits (0 or more), followed by some non-digits(0 or more).

It may be interesting if you think that new suffixes may come up in the future.

=SUM(IF(ISNUMBER(--LEFT(0&C17:G17&"A",ROW($1:$19)))*NOT(ISNUMBER(--LEFT(0&C17:G17&"A",ROW($2:$20)))),--LEFT(0&C17:G17&"A",ROW($1:$19))))
This in an array formula and so MUST be entered with CTRL+SHIFT+ENTER and not just ENTER.

Hope this helps
PGC
 
Upvote 0
Re: How can I sum a range that some cells have text and numb

Type this codes to Module1:

Code:
Function Split_Digits(CeL)
   Dim i As Integer
   For i = 1 To Len(CeL)
      DiGiT = Mid(CeL, i, 1)
      If IsNumeric(DiGiT) = True Then
         Split_Digits = Split_Digits & DiGiT
         Split_Digits = Split_Digits * 1
      End If
   Next i
End Function

Then;

C18 and slide to right the formula to G18
Code:
=Split_Digits(C17)

And for example to C19:
Code:
=SUM(C18:G18)

This actually worked for me! Thank you very much! :)
 
Upvote 0
For what it's worth, the above formula needs to be confirmed with CONTROL+SHIFT+ENTER...

I was searching for a formula for my needs. I have range ending in different numbers eg 123ab 123cd what if i wanted to sum numbers only ending in ad.
 
Upvote 0
also
=SUM(IF(RIGHT(A1:A5,2)="ad",VALUE(LEFT(A1:A5,LEN(A1:A5)-2)),0))
array entered (ctrl + shift + enter ) not just enter
 
Upvote 0

Forum statistics

Threads
1,223,980
Messages
6,175,763
Members
452,668
Latest member
mrider123

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