Find string and sum the column adjacent to the math - horizontally

javo

New Member
Joined
Sep 8, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a table where I'm trying to sum a quantity based on the value of the adjacent column. This is easy to do when you have one column for the range and the adjacent one for the quantity - and entries vertically. In my case, the quantity is always one column left from the type.

Number NewTypeNumber OldTypeproductquantitytypeproductquantitytypeproductquantitytype
A2 - How many newType?B2 - How many oldType?P12newTypeP220oldTypeP38newType

In column A2 I would expect: 10 (2+8)
In column B2 I would expect: 20

I've tried this formula, but it doesn't give the expected result:

=SUM(INDEX($C2:$K2,1,MATCH("newType",$C2:$K2,0)-1):INDEX($C2:$K2,1,MATCH("newType",$C2:$K2,0)-1))

Note: =COUNTIF($C2:$K2,"newType") gives me the number of occurrence of the right product, but not the quantity.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hi & welcome to MrExcel.
How about
+Fluff 1.xlsm
ABCDEFGHIJK
1Number NewTypeNumber OldTypeproductquantitytypeproductquantitytypeproductquantitytype
21020P12newTypeP220oldTypeP38newType
Master
Cell Formulas
RangeFormula
A2A2=SUMIFS(D2:J2,E2:K2,"Newtype")
B2B2=SUMIFS(D2:J2,E2:K2,"oldtype")
 
Upvote 0
Solution
Hi Fluff,
It works great! Not sure when I complicated things! Thanks a lot!
/Javo
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

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