Okay, here is a completely rewritten Soundex function that ignores
non-alphabetic letters completely...
Public Function Soundex(ByVal S As String) As String
Dim X As Long
Const CodeTab = " 123 12 22455 12623 1 2 2"
' abcdefghijklnmopqrstuvwxyz
If Len(S) = 0 Then Exit Function
S = UCase(S)
Soundex = Left(S, 1)
For X = 2 To Len(S)
If Mid(S, X, 1) Like "[A-Z]" Then
Soundex = Soundex & Mid(CodeTab, Asc(Mid(S, X, 1)) - 64, 1)
End If
Next
Soundex = Replace(Soundex, " ", "")
For X = 1 To 6
Do While InStr(Soundex, CStr(X) & CStr(X)) > 0
Soundex = Replace(Soundex, CStr(X) & CStr(X), CStr(X))
Loop
Next
Soundex = Left(Soundex & "0000", 4)
End Function
I don't want you to get the wrong idea about the accuracy of Soundex
functions in general... they are somewhat crude. Usually they are
implemented to give the user a choice of exact, or somewhat near, matches to
a string he/she types in. You may have seen versions of it implemented in
dictionaries where you type in, for example, fotograf and it returns several
possible words it 'thinks' you might have meant with the idea you will scan
the list and select the actual word (photograph) you meant. As for you
question about "A woman's love" and "A WOMANS LOVE", the function will
return the same code value, so you would conclude they are similar. However,
don't get too comfortable with the matches it returns the same code for "A
man is alive" too. I would say the main strength of the function is when it
is used on single words rather than multi-worded phrases or sentences.