Function StringsInString(psSearchIn, psSearchFor)
' Array holding words in string to search for.
Dim sSearchFor() As String
' Array holding words in string to search within.
Dim sSearchIn() As String
' Used to iterate through words in string to search for.
Dim iSearchForWords As Long
' Used to iterate through words in string to search within.
Dim iSearchInWords As Long
' Fill array with words in string to search for.
sSearchFor = Split(" " & psSearchFor, " ")
' Fill array with words in string to search within.
sSearchIn = Split(" " & psSearchIn, " ")
' Iterate through words to search for.
For iSearchForWords = 1 To UBound(sSearchFor)
' Iterate through words in string to search within.
For iSearchInWords = 1 To UBound(sSearchIn)
' Check if word to search for is in string to search within.
If sSearchFor(iSearchForWords) = sSearchIn(iSearchInWords) _
Then
' Add space between words found.
If StringsInString <> "" Then StringsInString = StringsInString & " "
' Add string found to return value.
StringsInString = StringsInString & sSearchFor(iSearchForWords)
End If
Next iSearchInWords
Next iSearchForWords
' Remove extra space at the end of the return string, if any.
StringsInString = Trim(StringsInString)
End Function