Hi I am trying to do a xLookup
on emails in different columns to check which one is duplicated.
The idea is to lookup an email in column, if it doesn't exist then move on to lookup in another column. For example, if Range("E1:E6").Value
is empty then lookup in range b and return any email dupes in that range. If not, move on to range c and so on.
Here is the native formula for easier reference:
*I'm also open to any alterative that achieves the same goal
Here is the vba code
Sub lookup()
Dim result AS Boolean
result = Range("E2:E6").Value
Range("E2:E6").Value = Application.XLookup(Range("D2:D6"), Range("A:A"), Range("A:A"))
If IsError(Range("E2:E6")).Value Then
Range("E2:E6").Value = Application.XLookup(Range("D2:D6"), Range("B:B"), Range("B:B"))
Else
Range("E2:E6").Value = Application.XLookup(Range("D2:D6"), Range("C:C"), Range("C:C"))
End If
End Sub
I expect the code to perform the lookup then if it's not found, move on to other columns to lookup
Thanks everyone