Excel Array formula

deveraux

Senior member
Mar 21, 2004
284
0
71
Hey guys,

I've been trying to learn more about array formulas (can't say I'm any good at them). Anyhow, I've been trying to essentially solve the following problem:

Say you have a database such as the following:

Code:
Item     Part      Price
i7       CPU       300
Phenom   CPU       200
5870     GFX       250
GTX295   GFX       300

Items bought
i7
5870
i7
GTX295

Basically, I need to figure out how to write a formula to essentially determine how much money is spent for say the CPU part or the GFX part. So, if I parse the value 'CPU' to the formula, it should return 600 (2x i7 bought). If I parse the value 'GFX', it should return 550 (250 + 300).

I know how to do this in VBA / custom function. But I'm trying to figure out how to do this using only array formulas etc. Any idea how I might go about doing this?

I have to admit, array formulas are my achilles heel. Anyway, any help on this would be greatly appreciated. Thank you!

PS: A little caveat, I do not wish to add any columns/rows etc to provide more info (I know it can be done if you add another column on the 'Items bought' list to lookup the part type). I'm just trying to figure out if this is possible as part of my learning.

EDIT: Fixing table formatting
 
Last edited:

Binky

Diamond Member
Oct 9, 1999
4,046
4
81
You could use sumproduct (which isnt an array), but I'm not seeing a way to do this in a single cell in the way you want it formatted.

If your data table shown is in cells A1-c4, and the "items bought" part is in A6-A10, then these formulas copied down through B7-B10 will pull the data you want from the table.

Code:
=SUMPRODUCT(($A$1:$C$4=A7)*($C$1:$C$4))
=SUMPRODUCT(($A$1:$C$4=A8)*($C$1:$C$4))
=SUMPRODUCT(($A$1:$C$4=A9)*($C$1:$C$4))
=SUMPRODUCT(($A$1:$C$4=A10)*($C$1:$C$4))

I don't see an elegant way to make this happen in a single cell.


Edit: Here's an array formula that works. I think this is how you were thinking it would work. It's a clunky formula because you have to point at each of the "items bought" individually.

Code:
=SUM((A1:A4=A7)*(C1:C4))+SUM((A1:A4=A8)*(C1:C4))+SUM((A1:A4=A9)*(C1:C4))+SUM((A1:A4=A10)*(C1:C4))
 
Last edited:

deveraux

Senior member
Mar 21, 2004
284
0
71
Thanks for the reply. Your single cell solution works, but as it requires knowing before hand the number of items bought and hard-coding it, I assume it may not be generalized into a formula that works with any number of line items.

Still, thank you very much for taking a stab at it.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |