OK
try this one
Function GetMaxCommon(ByVal txt As String, rng As Range _
, myGroup As Long, CSense As Boolean) As String
Dim r As Range, temp As String, m As Object
Dim flg As Boolean, myPtn As String
Static RegX As Object
If RegX Is Nothing Then
Set RegX = CreateObject("VBScript.RegExp")
RegX.Global = True
RegX.IgnoreCase = Not CSense
End If
With RegX
.Pattern = "([\^\|\\\$\(\)\-\+\*\?\[\]\.])"
txt = .Replace(txt, "\$1")
myPtn = Join$(Split(txt), "|")
For Each r In rng.Columns(1).Cells
If flg Then Exit For
If (r.Value <> txt) * (r(, 2).Value = myGroup) Then
temp = r.Value
With RegX
.Pattern = "(" & myPtn & ")"
If .test(temp) Then
GetMaxCommon = ""
For Each m In .Execute(temp)
GetMaxCommon = Trim$(GetMaxCommon & _
" " & m.submatches(0))
Next
.Pattern = "([\^\|\\\$\(\)\-\+\*\?\[\]\.])"
myPtn = Replace(.Replace(GetMaxCommon, "\$1"), " ", "|")
Else
GetMaxCommon = ""
flg = True
Exit For
End If
End With
End If
Next
End With
End Function
Bookmarks