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)
回车并向下填充。