Add data if column Match

J

JB Akron

I need to add data if sites match in one column (C). If they match, then
corresponding cell data from Column (B) are added together and as a sum in
Column D. If there is not a duplicate match it would be great if the cell
just carried over to Column D. The duplicates are not consistent and single
sites are intermixed. Column B is numeric, Column C is text

Example

B C D
1 s234 1

2 s235
5 s235 7
4 s236 4
5 s237
1 s237 6


Thank you for your input.
 
S

Shane Devenshire

Hi,

Try putting this in D2 and copying it down:

=IF(OR(C2="",C3=C2),"",B2+IF(C2=C1,B1))

Where I assume you have titles in row 1.
 
T

Teethless mama

Assuming titles in row 1

In D2:
=IF(C2="","",IF(LOOKUP(2,1/($C$2:$C$9=C2),ROW($C$2:$C$9)-1)=ROW()-1,SUMIF($C$2:$C$9,C2,$B$2:$B$9),""))

Copy down
Adjust your range to suit
 
T

T. Valko

That only works if there are 1 or 2 like items in column C. If there's more
than 2 you'll get incorrect results.

What should happen if there is something like this:

B....C.....D.....E
1.....x...............
1.....x.....2........
.........................
2.....x...............
5.....x.....7......9

Should the result be that as shown in column D or that as shown in column E?
Or, will that not happen?
 
J

JB Akron

Thanks

Shane Devenshire said:
Hi,

Try putting this in D2 and copying it down:

=IF(OR(C2="",C3=C2),"",B2+IF(C2=C1,B1))

Where I assume you have titles in row 1.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire
 
J

JB Akron

Thank you that is exactly what I was looking for

Teethless mama said:
Assuming titles in row 1

In D2:
=IF(C2="","",IF(LOOKUP(2,1/($C$2:$C$9=C2),ROW($C$2:$C$9)-1)=ROW()-1,SUMIF($C$2:$C$9,C2,$B$2:$B$9),""))

Copy down
Adjust your range to suit
 
S

Shane Devenshire

Hi,

If there are more than two occurances then you could use:

=IF(B2="","",IF(COUNTIF(C$2:C$9,C2)=COUNTIF(C$2:C2,C2),SUMIF(C$2:C2,C2,B$2:B2),""))

And if there are no blank rows you can shorten this to

=IF(COUNTIF(C$2:C$9,C2)=COUNTIF(C$2:C2,C2),SUMIF(C$2:C2,C2,B$2:B2),"")
 

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

Top