Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This macro loops through <code>Sheet1</code> and outputs all identical rows in the <code>Output</code> sheet. </p> <pre><code>Sub DeleteNonMatch() Dim i As Double Dim NotFound As Boolean Dim Inp As Worksheet, Out As Worksheet Dim r2 As Range, r3 As Range, r4 As Range, r5 As Range, r6 As Range 'Defines the sheets Set Inp = ActiveWorkbook.Sheets("Sheet1") 'Sheet with original dat Set Out = ActiveWorkbook.Sheets("Output") 'Output sheet 'Defines the searchable ranges input sheet Set r2 = Inp.Range(Inp.Range("G2").Address &amp; ":" &amp; Inp.Cells(Rows.Count, 7).End(xlUp).Address) Set r3 = Inp.Range(Inp.Range("M2").Address &amp; ":" &amp; Inp.Cells(Rows.Count, 13).End(xlUp).Address) Set r4 = Inp.Range(Inp.Range("S2").Address &amp; ":" &amp; Inp.Cells(Rows.Count, 19).End(xlUp).Address) Set r5 = Inp.Range(Inp.Range("Y2").Address &amp; ":" &amp; Inp.Cells(Rows.Count, 25).End(xlUp).Address) Set r6 = Inp.Range(Inp.Range("AE2").Address &amp; ":" &amp; Inp.Cells(Rows.Count, 31).End(xlUp).Address) 'Sets headers in output sheet With Out.Range("A1") .Offset(0, 0).Value = Inp.Range("A1").Value .Offset(0, 1).Value = Inp.Range("G1").Value .Offset(0, 2).Value = Inp.Range("M1").Value .Offset(0, 3).Value = Inp.Range("S1").Value .Offset(0, 4).Value = Inp.Range("Y1").Value .Offset(0, 5).Value = Inp.Range("AE1").Value End With 'Prints identical groups to output sheet For i = 2 To Inp.Cells(Rows.Count, 1).End(xlUp).Row Step 1 NotFound = False If r2.Find(Inp.Cells(i, 1).Value, , , xlWhole) Is Nothing Then NotFound = True If r3.Find(Inp.Cells(i, 1).Value, , , xlWhole) Is Nothing Then NotFound = True If r4.Find(Inp.Cells(i, 1).Value, , , xlWhole) Is Nothing Then NotFound = True If r5.Find(Inp.Cells(i, 1).Value, , , xlWhole) Is Nothing Then NotFound = True If r6.Find(Inp.Cells(i, 1).Value, , , xlWhole) Is Nothing Then NotFound = True If NotFound = False Then With Out.Cells(Out.Cells(Rows.Count, 1).End(xlUp).Row + 1, 1) .Offset(0, 0).Value = Inp.Cells(i, 1).Value .Offset(0, 1).Value = Inp.Cells(i, 1).Value .Offset(0, 2).Value = Inp.Cells(i, 1).Value .Offset(0, 3).Value = Inp.Cells(i, 1).Value .Offset(0, 4).Value = Inp.Cells(i, 1).Value .Offset(0, 5).Value = Inp.Cells(i, 1).Value End With End If Next i End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload