Hi!
I have 2 worksheets with extensive data from patient registry. What I want to do is go through worksheet2 row by row only in a single column(A). For each cell in every row in that specific column(A) I want to find that cell in worksheet1(which is 100% there, also in first column(A)) and delete the entire row. My code seems to almost work, problem is that it is missing a few ones. Why is that? Excuse my poorly written code this is not really my field. Thx in advance!
I have 2 worksheets with extensive data from patient registry. What I want to do is go through worksheet2 row by row only in a single column(A). For each cell in every row in that specific column(A) I want to find that cell in worksheet1(which is 100% there, also in first column(A)) and delete the entire row. My code seems to almost work, problem is that it is missing a few ones. Why is that? Excuse my poorly written code this is not really my field. Thx in advance!
Code:
Sub CheckA()
Dim LR As Long, i As Long, abc As Long, d As Variant
With Sheets("Sheet3")
LR = .Range("A" & Rows.Count).End(xlUp).Row
For i = LR To 1 Step -1
abc = Worksheets("sheet3").Range("A" & i).Value
Set d = Worksheets("sheet2").Range("A:A").Find(abc)
If Not d Is Nothing Then
d.EntireRow.Delete
Else
End If
Next i
End With
End Sub