Populate With Approximate Match

kumara_faith

Well-known Member
Joined
Aug 19, 2006
Messages
957
Office Version
  1. 365
Hi,

I have the following table:

Book1
BCD
1InteractionCase IDMatch
2Case ID: 554878 service recovery completed554868Yes
3Case ID 554879 service recovery completed555823Yes
4Case ID554899 service recovery completed554812No
5Case ID 555823 service recovery completed554878Yes
Sheet1


In column D , I am trying to match the case ID from column C to column B.

Criteria:
If the case ID matches exactly, then return Yes
If the case ID does not match by one digit but the word recovery and service exist in the same cell, then return Yes
If the case ID does not match by more than one digit even though the word service and recoverey exist in the same cell, return No

The correct answer is in column D.

Is this possible with a formula solution ? Appreciate all the help.
 
If the case ID does not match by one digit but the word recovery and service exist in the same cell, then return Yes
Can you just expand on the digit
would 654878 = 554878 - as 1 digit out
If the case ID does not match by more than one digit
so with that same example
would 564878 & 544878 = 554878 - as 1 digit out, as the 2nd digit is 5 - so 6 and 4 is only 1 out in 2nd digit, BUT 4 is 1 digit LESS so no math

may need some examples that do match and some that do not and why, as confused on that

What version of excel are you using - would be worth updating your profile to show version as solutions will be dependant on what version you have and therefore what functions available
 
Upvote 0
Hi,

Actually it could be any combination of 1 digit wrong. I have an updated table as below:

Book2.xlsx
BCD
1InteractionCase IDMatch
2Case ID: CC_55487887 service recovery completedCC_55487887Yes
3Case ID CC_55487958 service recovery completed CC_55582345Yes
4Case IDCC_55489911 service recovery completedCC_55489912Yes
5Case ID CC_55582345 service recovery completedCC_55487958Yes
6Case IDCC_55489922 service recovery completedCC_55489933No
Sheet1 (2)
 
Upvote 0
not sure i can help with this question
 
Upvote 0
@etaf, sorry to intervene
@kumara_faith, If you're comfortable in VBA, would you mind checking if this code works as expected
Book1
ABC
1InteractionCase IDMatch
2Case ID: 554878 service recovery completed554868Yes
3Case ID 554879 service recovery completed555823Yes
4Case ID554899 service recovery completed554812No
5Case ID 555823 service recovery completed554878Yes
6Case ID: CC_55487887 service recovery completedCC_55487887Yes
7Case ID CC_55487958 service recovery completedCC_55582345Yes
8Case IDCC_55489911 service recovery completedCC_55489912Yes
9Case ID CC_55582345 service recovery completedCC_55487958Yes
10Case IDCC_55489922 service recovery completedCC_55489933No
Sheet1

VBA Code:
Sub MatchCaseIds()
    Dim x2 As Worksheet
    Dim x3 As Long, x4 As Long
    Dim x5 As Long, x6 As Long
    Dim x7 As String, x8 As String
    Dim x9 As String
    Dim x10 As Boolean
    Dim x11 As Integer
    
    Set x2 = ActiveSheet
    
    x3 = x2.Cells(Rows.count, 1).End(xlUp).Row
    x4 = x2.Cells(Rows.count, 2).End(xlUp).Row
    
    For x5 = 2 To x4
        x8 = x12(x2.Cells(x5, 2).Value)
        x10 = False
        
        For x6 = 2 To x3
            x9 = LCase(x2.Cells(x6, 1).Value)
            x7 = x12(x9)
            
            If x7 = x8 Then
                x2.Cells(x5, 3).Value = "Yes"
                x10 = True
                Exit For
            End If
            
            If InStr(x9, "service") > 0 And InStr(x9, "recovery") > 0 Then
                x11 = x13(x7, x8)
                If x11 = 1 Then
                    x2.Cells(x5, 3).Value = "Yes"
                    x10 = True
                    Exit For
                End If
            End If
        Next x6
        
        If Not x10 Then x2.Cells(x5, 3).Value = "No"
    Next x5
    
    
End Sub

Function x12(x14 As String) As String
    Dim x15 As Integer, x16 As String
    x16 = ""
    
    For x15 = 1 To Len(x14)
        If Mid(x14, x15, 1) Like "[0-9]" Then
            x16 = x16 & Mid(x14, x15, 1)
        End If
    Next x15
    
    x12 = x16
End Function

Function x13(x17 As String, x18 As String) As Integer
    Dim x19 As Integer, x20 As Integer
    
    If Len(x17) <> Len(x18) Then
        x13 = 99
        Exit Function
    End If
    
    x20 = 0
    For x19 = 1 To Len(x17)
        If Mid(x17, x19, 1) <> Mid(x18, x19, 1) Then x20 = x20 + 1
    Next x19
    
    x13 = x20
End Function
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top