Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I delete duplicates between two excel sheets quickly vba
    primarykey
    data
    text
    <p>I am using vba and I have two sheets one is named "Do Not Call" and has about 800,000 rows of data in column A. I want to use this data to check column I in the second sheet, named "Sheet1". If it finds a match I want it to delete the whole row in "Sheet1". I have tailored the code I have found from a similar question here: <a href="https://stackoverflow.com/questions/3426205/excel-formula-to-cross-reference-2-sheets-remove-duplicates-from-one-sheet">Excel formula to Cross reference 2 sheets, remove duplicates from one sheet</a> and ran it but nothing happens. I am not getting any errors but it is not functioning. </p> <p>Here is the code I am currently trying and have no idea why it is not working</p> <pre><code>Option Explicit Sub CleanDupes() Dim wsA As Worksheet Dim wsB As Worksheet Dim keyColA As String Dim keyColB As String Dim rngA As Range Dim rngB As Range Dim intRowCounterA As Integer Dim intRowCounterB As Integer Dim strValueA As String keyColA = "A" keyColB = "I" intRowCounterA = 1 intRowCounterB = 1 Set wsA = Worksheets("Do Not Call") Set wsB = Worksheets("Sheet1") Dim dict As Object Set dict = CreateObject("Scripting.Dictionary") Do While Not IsEmpty(wsA.Range(keyColA &amp; intRowCounterA).Value) Set rngA = wsA.Range(keyColA &amp; intRowCounterA) strValueA = rngA.Value If Not dict.Exists(strValueA) Then dict.Add strValueA, 1 End If intRowCounterA = intRowCounterA + 1 Loop intRowCounterB = 1 Do While Not IsEmpty(wsB.Range(keyColB &amp; intRowCounterB).Value) Set rngB = wsB.Range(keyColB &amp; intRowCounterB) If dict.Exists(rngB.Value) Then wsB.Rows(intRowCounterB).delete intRowCounterB = intRowCounterB - 1 End If intRowCounterB = intRowCounterB + 1 Loop End Sub </code></pre> <p>I apologize if the above code is not in a code tag. This is my first time posting code online and I have no idea if I did it correctly.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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