Find every occurrence of a specified value and return the sum product of A1 from each row where a value was found.

Epoch18

New Member
Joined
Jul 14, 2017
Messages
4
Hi there.

I've been banging my head on this for too long, and everything I search up never gets me to the right place. So here is the scenario, and what I am looking for.

Data:
My data is given to me as converted from JSON, which means that the headers are never in the same place, except for the first few. Luckily the value I want to sum is always in column A.
Example:
ABCDEFGHIJ
1ValueAccountName1Name2Name3Name4Name5Name6Name7Name8
2150000AcmeKyleSamSarahTimMelissaBrianLauraKarl
3250000WalmartSarahKyleKenny
450000TargetSarahTim
5325000KmartMelissaGeorgeKennyLaura

<tbody>
</tbody>


Parameters:
I have a list of all of my employee names on a separate tab. These should be my search parameters for each row in my data.
Example:
Brian
George
Karl
Kenny
Kyle
Laura
Melissa
Sam
Sarah
Tim


Results:
Next to each of my employee names, I want to see the total sum of each value is A1 for every row that each employee name is present. As you can see from my data example, the names are almost never in the same column. So, if "Laura" exists anywhere within rows 2 and 5, then the number next to her name should be "475000" (the sum of A2 and A5).

I would greatly appreciate any ideas.

Thank you!
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Ready for some ugly, dirty looking but gets the job done code?
Code:
=SUM(IF(COUNTIF(B2:J2,"Laura") > 0,A2,0),IF(COUNTIF(B3:J3,"Laura") > 0,A3,0),IF(COUNTIF(B4:J4,"Laura") > 0,A4,0),IF(COUNTIF(B5:J5,"Laura") > 0,A5,0))

Basically each "number" is:
Code:
IF(COUNTIF(B2:J2,"Laura") > 0,A2,0)
Just change the range, the number to grab, and the name to search for to suit your needs.
 
Upvote 0
Assuming data in Sheet1, maybe...

B1 copied down
=SUMPRODUCT((Sheet1!C$2:J$5=A1)*(Sheet1!$A$2:$A$5))

Hope this helps

M.
 
Upvote 0
This could get very messy. Each data sheet is at least 200 rows and there's a new one each month. I don't think this is a viable solution, though I do appreciate your response.
 
Upvote 0
Assuming data in Sheet1, maybe...

B1 copied down
=SUMPRODUCT((Sheet1!C$2:J$5=A1)*(Sheet1!$A$2:$A$5))
This doesn't specify any employee names. Thank you though.
It doesn't have to specify any names... you are assumed to have done that already. Marcelo assumed your data was on Sheet1 and that on a different sheet, starting in cell A1 on that different sheet, is the list of names you showed in your original message. So, Marcelo is instructing you to place his formula in cell B1 on that different sheet and copy it down to the end of your list of names.
 
Last edited:
Upvote 0
This doesn't specify any employee names. Thank you though.

It doesn't have to specify any names... you are assumed to have done that already. Marcelo assumed your data was on Sheet1 and that on a different sheet, starting in cell A1 on that different sheet, is the list of names you showed in your original message. So, Marcelo is instructing you to place his formula in cell B1 on that different sheet and copy it down to the end of your list of names.

That's it! Thank you, Rick.

M.
 
Upvote 0
It doesn't have to specify any names... you are assumed to have done that already. Marcelo assumed your data was on Sheet1 and that on a different sheet, starting in cell A1 on that different sheet, is the list of names you showed in your original message. So, Marcelo is instructing you to place his formula in cell B1 on that different sheet and copy it down to the end of your list of names.

You're right. I didn't really see what the formula was doing. But I tried it out and it appears to be working.

Thank you, both!
 
Upvote 0

Forum statistics

Threads
1,215,507
Messages
6,125,212
Members
449,214
Latest member
mr_ordinaryboy

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