Add cells containing certain text and numbers

acura123

Board Regular
Joined
Jul 13, 2003
Messages
87
I want to be able to add the numerical values of cells containing a certain word. Lets say Apples

For Example:

Data

2 apples

grapes 6

apples 10

6 pears


Thanks

Answer: Number of Apples: 14
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
This formula did't work

All the data is in the same column

My fault. Try not to describe the issue you have with a formula with "didn't work" for it does not help to diagnose the problem, although I think you had a #VALUE! error with that formula.

Here is remedy...
Book13
ABCD
1
22 applesapples12
3grapes 6grapes6
4apples 10
56 pears
Sheet1


D2:

=SUM(IF(ISNUMBER((0&TRIM(SUBSTITUTE(UPPER(A2:A5),UPPER(C2),"")))+0),(0&TRIM(SUBSTITUTE(UPPER(A2:A5),UPPER(C2),"")))+0,0))

which is confirmed with control+shift+enter (not just with enter) then copied down.
 
Upvote 0
The count I am getting is 0

I think because the words contain other words in front of them and behind them.

EX. 6 Green Pears
Fancy Pears 5

Where the refrence cell is "pears"
 
Upvote 0
The count I am getting is 0

I think because the words contain other words in front of them and behind them.

EX. 6 Green Pears
Fancy Pears 5

Where the refrence cell is "pears"

Obviously...

Options:

1] Separate text from figures and then do the required calculations.
2] Sollicite code in VBA if you don't want to go with [1].
3] Download and install the morefunc.xll add-in in order to have a set up like below if you don't want to follow either [1] or [2]...
aaCondSumCellsWithTextAndNumbers acura123.xls
ABCDE
1
22 apples2apples12
3grapes 66grapes6
4apples 1010pears6
56 green pears6
6
Sheet1


B2:

=MCONCAT(IF(ISNUMBER(SETV(--MID(A2,INTVECTOR(LEN(A2),1,1),1))),GETV(),""))+0

which is confirmed with control+shift+enter (not just with enter) then copied down.

E2, copied down:

=SUMIF($A$2:$A$5,"*"&D2&"*",$B$2:$B$5)
 
Upvote 0
In the example you gave (6 Green Pears, Fancy Pears 5) do you wish to calculate separately the number of Green Pears and of Fancy Pears, or just you wish to calculate 11 Pears? In this second case, do you have a list of items that you wish to count, in wich format?

Bye,
 
Upvote 0

Forum statistics

Threads
1,214,629
Messages
6,120,630
Members
448,973
Latest member
ChristineC

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