Good morning! I wanted to see if someone could help me modify this VBA code. As it is now, I have 3 columns that search for duplicates, consolidate, and then add the total qty.
I only want to add a 4th column with initials at the end.
This is my current VBA code for the sample spreadsheet above. My new edit would look like this:
Please let me know if this is enough information! Thank you all!
I only want to add a 4th column with initials at the end.
Part Number | Manufacturer | QTY |
1234A | SONY | 50 |
1234A | SONY | 150 |
1234B | ON | 15000 |
1234C | NEW | 99000 |
VBA Code:
Sub Consolidate()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lrow As Long
Dim i As Long
Set ws1 = ActiveSheet
Set ws2 = ActiveWorkbook.Worksheets.Add
ws2.Name = "ONLINEINV3"
lrow = ws1.Cells(Rows.Count, 1).End(xlUp).Row
ws1.Range("A1:B" & lrow).Copy ws2.Range("A1")
ws2.Range("A:B").RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
ws2.Range("C1") = "FULL PARTNO"
ws2.Range("D1") = "QTY"
lrow = ws2.Cells(Rows.Count, 1).End(xlUp).Row
For i = 2 To lrow
ws2.Cells(i, 3) = ws2.Cells(i, 2) & " " & ws2.Cells(i, 1)
ws2.Cells(i, 4) = Application.SumIfs(ws1.Range("C:C"), ws1.Range("A:A"), ws2.Cells(i, 1), ws1.Range("B:B"), ws2.Cells(i, 2))
Next i
End Sub
This is my current VBA code for the sample spreadsheet above. My new edit would look like this:
Part number | Manufacturer | Qty | Comments |
1234A | SONY | 50 | AK02 |
1234A | SONY | 150 | AK02 |
1234B | ON | 15000 | RC03 |
1234C | NEW | 99000 | WB01 |
Please let me know if this is enough information! Thank you all!