SUM() Cell That Contains String&Integer

Dtex20

Board Regular
Joined
Jan 29, 2018
Messages
50
Hi Guys,

I've been searching for a day or two now to find exactly what i want, but i can't seem to find it anywhere.

The problem i have there is a column with numbers and strings.

5
10D
51
Pax
40D
21


Now i want to add all the numbers with a "D" next to it, and ignore the integer cells and ignore the string cells. So the answer to the example above would be 50. 10D + 40D

Is there a way to do this in a formula, I've searched for similar things but nothing that meets the exact requirement.

Thanks for your help.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Assuming the values in A2:A7, maybe...

Array formula
=SUM(IF(ISNUMBER(SEARCH("D",A2:A7)),IFERROR(--SUBSTITUTE(A2:A7,"D",""),0)))
confirmed with Ctrl+Shift+Enter, not just Enter

Hope this helps

M.
 
Upvote 0
=SUM(IF(ISNUMBER(SEARCH("D",A1:A6)),SUBSTITUTE(A1:A6,"D","")+0))
Array formula, use Ctrl-Shift-Enter
 
Upvote 0
Thankyou so much guys, exactly what i need!

I would of never of thought to substitute the "D".
 
Upvote 0
As a precaution...

Replace the bit

SUBSTITUTE(A1:A6,"D","")

with

SUBSTITUTE(UPPER(A1:A6),"D","")

Yes, good point - SUBSTITUTE is case sensitive.
Besides that it's important to wrap SUBSTITUTE with IFERROR(..,0) - in case there is something like DAX in the data.

M.
 
Upvote 0

Forum statistics

Threads
1,223,959
Messages
6,175,647
Members
452,663
Latest member
MEMEH

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