formula help - maybe vlookup, not sure

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

Guest

here's the logic. i have an ID which could have anywhere from 1-5 entries.
for each ID, i want to sum what's in the column next to it. for example -
column a column b column C
ID 123 $20 $44
ID 123 $24
ID 125 $23
ID 125 $12
ID 111 $10
is there a way to look at whats in column A and do the sum for whats in
column B and put that total in column C?
 
Assuming you have headers in row 1, enter this into cell C2, and copy down to match your table:

=IF(COUNTIF($A$2:A2,A2)=1,SUMIF(A:A,A2,B:B),"")

This will only put the sum at the first instance of a new value in column A. If you want each row
to have the sum, just use

=SUMIF(A:A,A2,B:B)

HTH,
Bernie
MS Excel MVP
 
this part worked. a follow up is what if i have 2 columns of data to add? i
tried
d1: =SUMIF(A:A,A1,B:C) but it does't add what's in column b and c. is
there an easy way to do that?
 
this is exactly what i need, only to put it in the first instance. now the
question is, how do i add columns b and c? my example below only said b but
i tried what seemed logically correct and it's not working.
 
Assuming you have headers in row 1, enter this into cell C2, and copy down
to match your table:

=IF(COUNTIF($A$2:A2,A2)=1,SUMIF(A:A,A2,B:B)+SUMIF(A:A,A2,C:C),"")

This will only put the sum at the first instance of a new value in column A.
If you want each row
to have the sum, just use

=SUMIF(A:A,A2,B:B)+SUMIF(A:A,A2,C:C)

HTH,
Bernie
MS Excel MVP
 
d1: =SUMIF(A:A,A1,B:C)

One way is to use 2 SUMIFs, eg:
=SUMIF(A:A,A1,B:B)+SUMIF(A:A,A1,C:C)
 

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