Flexible Pattern Match (Best Version So Far 071024)

Refined Pattern Matching Function

Vba '''

Function FlexiblePatternMatch(lookupValue As String, lookupRange As Range, returnRange As Range) As Variant

Dim i As Long

Dim lookupWords() As String

Dim currentWords() As String

Dim lookupCombinations As Collection

Dim currentCombinations As Collection

Dim bestMatchIndex As Long

Dim maxCommonWords As Long

Dim commonWordsCount As Long

Dim matches As Collection

Dim match As Variant

' Initialize the best match index to -1 (indicating no match found)

bestMatchIndex = -1

maxCommonWords = 0

Set matches = New Collection

' Check for exact match first

For i = 1 To lookupRange.Rows.count