'可以用VBA实现
'Alt+F11打开VBA, 加入如下代码
Sub Macro3() '已验证
Dim iARow As Integer, iBRow As Integer
Dim iARowMax As Integer, iBRowMax As Integer
Dim iTarRow As Integer
Dim sA As String, sB As String
iARowMax = 1
While ActiveSheet.Cells(iARowMax, 1) <> ""
iARowMax = iARowMax + 1
Wend
iBRowMax = 1
While ActiveSheet.Cells(iBRowMax, 1) <> ""
iBRowMax = iBRowMax + 1
Wend
iTarRow = 1
For iARow = 1 To iARowMax - 1
sA = Right(ActiveSheet.Cells(iARow, 1), 1)
For iBRow = 1 To iBRowMax - 1
sB = Left(ActiveSheet.Cells(iBRow, 2), 1)
If sA = sB Then
ActiveSheet.Cells(iTarRow, 3) = "'" & ActiveSheet.Cells(iARow, 1) & _
Mid(ActiveSheet.Cells(iBRow, 2), 2)
iTarRow = iTarRow + 1
End If
Next iBRow
Next iARow
End Sub
我感觉先分裂、再VLOOKUP、再合并,希望可以给你启发
VLOOKUP显然不能满足复数个场合。此题需要VBA才行。
看似很复杂的