# Solved: vlookup and sumif in Excel

Discussion in 'Business Applications' started by deastew, Feb 27, 2013.

Not open for further replies.

Joined:
Dec 5, 2012
Messages:
14
I would like to create a formula that sums the value in column B for each time the number in column A appears. In essence, I want a formula to return numbers in column D. I tried using the following formula but it did not work:

=SUMIF(A2:A9,VLOOKUP(C2,A:B,2,FALSE),B2:B9)

Column A Column B Column C Column D
991 0 991 2
992 1 992 4
993 0 993 0
994 5 994 7
991 2
992 3
993 0
994 2

Thanks

2. ### etafModerator

Joined:
Oct 2, 2003
Messages:
65,184
First Name:
Wayne
in c2 put
Code:
```=IF(OR(INDEX(\$A\$2:\$A\$10,MATCH(0,INDEX(COUNTIF(\$C\$1:C1,\$A\$2:\$A\$10),0,0),0))=0,ISERROR(INDEX(\$A\$2:\$A\$10,MATCH(0,INDEX(COUNTIF(\$C\$1:C1,\$A\$2:\$A\$10),0,0),0)))),"",INDEX(\$A\$2:\$A\$10,MATCH(0,INDEX(COUNTIF(\$C\$1:C1,\$A\$2:\$A\$10),0,0),0)))
```
and copy down
in D2 put
Code:
`=IF(C2="","",SUMIF(A2:A9,C2,B2:B9))`
see attached

#### Attached Files:

• ###### Sum Unique etaf.xlsx
File size:
10.2 KB
Views:
35

Joined:
Dec 5, 2012
Messages:
14
Thank you so much!!! It worked!

Joined:
Oct 2, 2003
Messages:
65,184
First Name:
Wayne

As Seen On