excel 求兩個字符串的相同部分
Atl+F11——菜單欄——插入——模塊,粘貼以下代碼:
Function J(a As String, b As String) As String
Dim i As Integer, t, d As Object
Set d = CreateObject("Scripting.Dictionary")
For i = 1 To Len(b)
t = Mid(b, i, 1)
If InStr(a, t) Then d(t) = d(t)
Next
t = d.keys
J = Join(t, "")
Set d = Nothing
End Function
關閉VBA窗口。
在C1輸入
=J(A1,B1)
回車並向下填充。