summing an array by product category

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need help writing a macro that will look down the first column and will add
up the prices of whatever rows that have the same category.

Example:
category product price
pets horse 100
pets dog 50
food banana .50
food hamburger 1.50

pets subtotal: 150
food subtotal: 2.00

Thank you very much.

BLW
 
Hi
It is possible to do this without a macro using SUMPRODUCT or SUMIF. If you
don't specifically need a macro, post back and we'll respond for you!

Andy.
 
Andy, I don't specifically need to use a macro so long as I can continually
select more products and the subtotals change with the new selection. In any
case, I would like to see how the two functions you described are use.
Thanks a lot
 
=SUMPRODUCT(--(A1:A100="pets"),C1:C100)

or

=SUMIF(A1:A100,"pets",C1:C100)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top