delete pairs of 2 identical numbers macro

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
510
Office Version
  1. 365
Platform
  1. Windows
hello!

how to rule out (delete) 2 set's of 2 identical numbers in any order?
and also set's of 4
with a macro please

example for deletion:
1 1 2 2
5 8 8 5
1 2 1 2
7 7 7 7


sheet1
ABCDE
11122delete
21123
31124
41125
51126
61127
71128
81132
91133delete
101134
111122delete
125885delete
131212delete
147777delete
22
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
VBA Code:
Sub DelDup()
Dim col As New Collection, lastrow As Long, x As Long, i As Long
lastrow = Range("A" & Rows.Count).End(xlUp).Row
For x = 1 To lastrow
    If Range("A" & x) = Range("B" & x) And Range("C" & x) = Range("D" & x) Or _
    Range("A" & x) = Range("D" & x) And Range("C" & x) = Range("B" & x) Or _
    Range("A" & x) = Range("C" & x) And Range("B" & x) = Range("D" & x) Then col.Add x
Next x
For i = col.Count To 1 Step -1
    Rows(col(i)).Delete
Next i
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,978
Messages
6,122,549
Members
449,089
Latest member
davidcom

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