If Column A has duplicates then add the value in column D for the duplicates

EquipmentPartsSales

New Member
Joined
Sep 17, 2018
Messages
6
I have a large inventory file I am working with. The data looks like this:
NSNPart numberConditionQTYDESC
100500195089711662739NS7MOTOR
100500195089711662739NS2MOTOR
1005002676740368506201NS4HOUSING
10050050132015013201NS1SPRING

<tbody>
</tbody>

Basically what I would like to do is if the number in column NSN has a duplicate then add up the values in the QTY column. For this example it would like like this:
NSNPart numberConditionQTYDESCTotal Qty
100500195089711662739NS7MOTOR9
100500195089711662739NS2MOTOR
1005002676740368506201NS4HOUSING
10050050132015013201NS1SPRING

<tbody>
</tbody>

I do not know if there is a simple formula or a VBA code that will achieve this. My inventory list has roughly 200,000 lines. Any help would be greatly appreciated.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Hi,

Is this what you mean:


Book1
ABCDEF
1NSNPart numberConditionQTYDESCTotal Qty
2100500195089711662739NS7MOTOR9
3100500195089711662739NS2MOTOR
41005002676740368506201NS4HOUSING
510050050132015013201NS1SPRING
Sheet268
Cell Formulas
RangeFormula
F2=IF(AND(COUNTIF(A$2:A2,A2)=1,COUNTIF(A$2:A$200000,A2)>1),SUMIF(A$2:A$200000,A2,D$2:D$200000),"")


Formula copied down.
 
Upvote 0
Code:
=countif(A:A,A2)

Replace A with whatever column NSN is and A2 with whatever the first row of data is after column header.



I found a VBA code as well that is currently running I will try this right after I did not want to drag the code down 200,000 lines. Thank you very much for your response it is greatly appreciated.
 
Upvote 0
I tried this one first or at least something very similar. It puts the total qty in line with the lowest duplicate like this:

1NSNPart numberConditionQTYDESCTotal Qty
2100500195089711662739NS7MOTOR
3100500195089711662739NS2MOTOR9
41005002676740368506201NS4HOUSING
510050050132015013201NS1SPRING


<tbody>
</tbody>

The problem with that is when I use VBA to change the duplicates to blanks it only saves the first one. When I would go to delete the row I would lose the data.


Fixed the post
 
Upvote 0
I tried this one first or at least something very similar. It puts the total qty in line with the lowest duplicate like this:

1NSNPart numberConditionQTYDESCTotal Qty
2100500195089711662739NS7MOTOR
3100500195089711662739NS2MOTOR9
41005002676740368506201NS4HOUSING
510050050132015013201NS1SPRING


<tbody>
</tbody>

The problem with that is when I use VBA to change the duplicates to blanks it only saves the first one. When I would go to delete the row I would lose the data.


Fixed the post

I'm not understanding this comment, and don't know if you're referring to my Post # 3.

Also, if using a formula solution, there's no need to "physically" copy the formula down 200000 rows.

Let me know if my formula is doing what you need, and I'll respond accordingly.
 
Upvote 0
I'm not understanding this comment, and don't know if you're referring to my Post # 3.

Also, if using a formula solution, there's no need to "physically" copy the formula down 200000 rows.

Let me know if my formula is doing what you need, and I'll respond accordingly.


Not trying to sound rude I truly do not know how do you get the formula all the way down without dragging it?
 
Upvote 0
No, not sounding rude at all, I just didn't know who you were talking to, and still don't know if my formula is working for you.

The other formula offered above Only does a COUNT of Column A, whereas, according to your description you want a SUM of Column D (Qty) for Duplicates in Column A, but ignore the unique NSN(s) in Column A (as my formula does).

Anyway, using my table in Post # 3 as sample, to quickly copy F2 formula All the Way to F200000:

1. Select F2, Right click, Copy
2. Hit F5, inside the "Reference" box, type F3:F200000
3. Hold down Shift, Click "OK"
4. Control V, the formula is now copied All the way down to F200000
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top