我有 4 列数据。它们是复制并粘贴在一起的名字/姓氏列的两个单独列。
我想要做的是对姓氏进行匹配,如果它们相等,则对名字进行匹配。
列范围是动态的,这就是运行 CONCATENATE 和 VLOOKUP 公式有效的原因,但如果我能少涉及一些东西,那就太好了。
A B C D E
1 Last First Last2 First2
2 Sharma Abhi Smith Kevin
3 Philip Matt Smith GEORGIA
4 Franc Pete John Bon Jovi
5 Arnold Susan Jack White
6 Mallo Chad Sharma Katie
7 Daigle Steve Sharma Abhi
我的想法是,从单元格 E2 开始,它应该返回匹配或不匹配(在这种情况下,只有第 2 行应该返回匹配。目前它每次都返回匹配 - 这绝对是不正确的。
这是我到目前为止写的代码
Sub matchFunction()
On Error Resume Next
Dim BW_Row As Long
Dim BW_Clm As Long
Table1 = Sheet2.Range("F11:F16") ' Range of all appointments last name
Table2 = Sheet2.Range("$G$11:$G$16") ' Range of all appointments first name
Table3 = Sheet2.Range("$H$11:$H$16") ' Range of leads
BW_Row = Sheet2.Range("J11").Row ' Change E column if it's a match
BW_Clm = Sheet2.Range("J11").Column
For Each c In Table1
For Each d In Table2
If Application.Match(c, Table3, 0) <> "" Then
If Application.Match(d, Table3, 0) <> "" Then
Sheet2.Cells(BW_Row, BW_Clm) = "It's a Match!"
Else
Sheet2.Cells(BW_Row, BW_Clm) = "Sorry, it's not a match"
End If
End If
BW_Row = BW_Row + 1
Next d
Next c
MsgBox "Matching Finished"
End Sub