PDA

View Full Version : Solved: Find unique records



av8tordude
06-14-2011, 08:45 AM
Record A (A:B) has less records than Record B (D:E). Can someone assist with a vba code that will paste the missing records into column G:H. thanks

shrivallabha
06-14-2011, 09:22 AM
Are you interested in:
Countries Only or Countries & Rates combined.

#1] If it is countries only then:
VLOOKUP can point it out. Will you still need VBA?

#2] If it is both then not a single record matches.

av8tordude
06-14-2011, 09:33 AM
shrivallabha, Vba would be preferrable and appreciated. Thanks

shrivallabha
06-14-2011, 11:11 AM
The entries in Column D which are not found in Column A will be pasted in Column F.
Public Sub FindMissingEntries()
Dim lLastRow1 As Long, lLastRow2 As Long
Dim r As Range
lLastRow1 = Range("D" & Rows.Count).End(xlUp).Row
lLastRow2 = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To lLastRow1
Set r = Range("A2:A" & lLastRow2).Find(What:=Range("D" & i).Value2, LookIn:=xlValues, LookAt:=xlWhole)
If r Is Nothing Then
Range("F" & Rows.Count).End(xlUp)(2) = Range("D" & i).Value2
End If
Next i
End Sub

av8tordude
06-14-2011, 11:47 AM
Thank you, shrivallabha. Works great.:friends: