delete 12000 rows contains duplicates items

leap out

Active Member
Joined
Dec 4, 2020
Messages
288
Office Version
  1. 2016
  2. 2010
Hi

I need macro to delete about 12000 rows for the duplicates items between two sheets . but should match duplicates items for the whole range . if the values are different for the same item should not be deleted.
OFFTHEL.xlsm
ABC
1ITEMGOODSQTY
2110W40 12x1L Q8 EU200
3210W40 12x1L CAS SU120
4310W40 12x1L ENI IT300
54OL-115W40 12x1L CAS SU**2240
65 MLO-1 10W40 208L TT/L CAS SU150
7610W40 208L ENI IT160
875W30 208L Q8 EU200
98OIL/M 10W40 4x4L CAS TRM SU N3-90120
rep



OFFTHEL.xlsm
ABC
1ITEMGOODSQTY
2110W40 12x1L Q8 EU100
32 MLO-1 10W40 208L TT/L CAS SU120
4310W40 208L ENI IT160
545W30 208L Q8 EU200
65OIL/M 10W40 4x4L CAS TRM SU N3-90120
7610W40 12x1L CAS SU120
8710W40 12x1L ENI IT300
98OL-115W40 12x1L CAS SU**2240
109OL-115W40 12x1L CAS SU**31000
1110OL-115W40 12x1L CAS SU**41200
1211OL-115W40 12x1L CAS SU**5120
1312OL-115W40 12x1L CAS SU**6200
stock


delete the items should be from sheet STOCK
the result
OFFTHELP.xlsm
ABC
1ITEMGOODSQTY
2110W40 12x1L Q8 EU100
32 MLO-1 10W40 208L TT/L CAS SU120
43OL-115W40 12x1L CAS SU**31000
54OL-115W40 12x1L CAS SU**41200
65OL-115W40 12x1L CAS SU**5120
76OL-115W40 12x1L CAS SU**6200
output
D=h:c|v:m|fz:10pt|cls:ww]200[/XD][/XR][/RANGE]
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try this:

VBA Code:
Sub deleteduplicates()
  Dim dic As Object
  Dim a, b, c
  Dim i As Long, j As Long
  
  Set dic = CreateObject("Scripting.Dictionary")
  a = Sheets("rep").Range("A2", Sheets("rep").Range("C" & Rows.Count).End(3)).Value
  b = Sheets("stock").Range("A2", Sheets("stock").Range("C" & Rows.Count).End(3)).Value
  ReDim c(1 To UBound(b, 1), 1 To 3)
  
  For i = 1 To UBound(a, 1)
    dic(a(i, 2) & "|" & a(i, 3)) = Empty
  Next
  
  For i = 1 To UBound(b)
    If Not dic.exists(b(i, 2) & "|" & b(i, 3)) Then
      j = j + 1
      c(j, 1) = j
      c(j, 2) = b(i, 2)
      c(j, 3) = b(i, 3)
    End If
  Next
  
  Sheets("output").Range("A2").Resize(j, 3).Value = c
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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