If duplicate found sum column C

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

Guest

I have information in column A, B and C. If column A and B match then sum
the qty of the duplicates in column D. Can someone help with a formula that
would accomplish this?

Column A Column B Column C Column D
Order Item Qty Sum of Duplicates
23580351 04827 5
23580351 04827 5
23580358 04827 5
23580361 04827 5
23580361 04827 5
23580368 04827 5
 
Assumptions: First is that you meant to sum the duplicate rows rather than
columns, since your illustration does not indicate the probability of a match
between column A and B. If this assumption is false, then the code fails.

File is sorted by order number so that duplicates will be grouped.
There are no more than two rows for any group of duplicates. If there are
more than two then this macro fails. A different and more complex code must
be used if there are more than two duplicates.

Here is the code:

Sub SumDupRow()

lr = Cells(Rows.Count, 1).End(xlUp).Row
Range("$A$1").Activate
Do
For i = 1 To lr
x = ActiveCell.Address
If Range(x).Value = Range(x).Offset(1, 0).Value And
Range(x).Offset(0, 1).Value = Range(x).Offset(1, 1).Value Then
Range(x).Offset(0, 3) = Range(x).Offset(0,2).Value +
Range(x).Offset(1,2)
End If
Next i
Range(x).Offset(1, 0).Activate
Loop Until Range(x) = ""
End Sub
 

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

Similar Threads

SUM - IF - AND 7
Multiple SUM's in a column 15
Transpose?? 6
Formula needed to SUM and COUNT in specific way 1
Edit a GETPIVOTDATA formula? 5
Weighted randbetween text list 3
Need largest number 6
Sumproduct 1

Back
Top