我正在为电气设备编译 BOM。我总共有 18 个 BOMS,每个 BOMS 大约有 160 个项目。我正在寻找一种代码,它可以扫描所有数据并识别重复项,获取它们的值,将它们相加,然后删除重复项。我已经识别并删除了此代码,但我无法将其加起来...
Sub RemoveDuplicates()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "B").End(xlUp).Row
For x = lastrow To 1 Step -1
For y = 1 To lastrow
If Cells(x, 1).Value = Cells(y, 1).Value And Cells(x, 2).Value = Cells(y, 2).Value And x > y Then
Cells(y, 3).Value = Cells(x, 3).Value + Cells(y, 3).Value
Rows(x).EntireRow.Delete
Exit For
End If
Next y
Next x
End Sub