TextPercentageMatch

Matching any part of a string in another , then returns 0 if not match, Or returns the percentage of matching if found
' Uses words, and word separators [space]-,_.

CodeFunctionName
What is this?

Public

Tested

Original Work
Function TextPercentageMatch(OfText, inText)
TextPercentageMatch = 0
St1 = OfText
Coco1 = InStr(1, inText, St1, vbTextCompare)
If Coco1 > 0 Then
TextPercentageMatch = Len(St1) / Len(inText)
Exit Function
End If
For i = Len(OfText) To 1 Step -1
If Mid(OfText, i, 1) = " " Or Mid(OfText, i, 1) = "-" Or Mid(OfText, i, 1) = "_" Or Mid(OfText, i, 1) = "." Or Mid(OfText, i, 1) = "," Then
St2 = Left(OfText, i - 1)
Coco1 = InStr(1, inText, St2, vbTextCompare)
If Coco1 > 0 Then
TextPercentageMatch = Len(St2) / Len(OfText)
Exit Function
End If
End If
Next
For i = 1 To Len(OfText)
If Mid(OfText, i, 1) = " " Or Mid(OfText, i, 1) = "-" Or Mid(OfText, i, 1) = "_" Or Mid(OfText, i, 1) = "." Or Mid(OfText, i, 1) = "," Then
St2 = Left(OfText, i - 1)
Coco1 = InStr(1, inText, St2, vbTextCompare)
If Coco1 > 0 Then
TextPercentageMatch = Len(St2) / Len(OfText)
Exit Function
End If
End If
Next
End Function

OfText, inText

Views 3,960

Downloads 1,340

CodeID
DB ID