How to compare text string of two different columns in Excel
Hi friends recently I am trying to make the macros in Excel so that I compare the two different texts String Present in two different cells of two different columns in Excel, but however I am not able to create such tough macros or formula that I can make use. So if you guys have any ideas then please let me know.
Re: How to compare text string of two different columns in Excel
Try this logic may it help you to make the comparison of two different Text string in Excel
Quote:
Dim TopMatch As Integer
Dim strCompare As String
Function Fuzzy(strIn1 As String, strIn2 As String) As Single
Dim L1 As Integer
Dim In1Mask(1 To 24) As Long 'strIn1 is 24 characters max
Dim iCh As Integer
Dim N As Long
Dim strTry As String
Dim strTest As String
TopMatch = 0
L1 = Len(strIn1)
strTest = UCase(strIn1)
strCompare = UCase(strIn2)
For iCh = 1 To L1
In1Mask(iCh) = 2 ^ iCh
Next iCh
For N = 2 ^ (L1 + 1) - 1 To 1 Step -1
strTry = ""
For iCh = 1 To L1
If In1Mask(iCh) And N Then
strTry = strTry & Mid(strTest, iCh, 1)
End If
Next iCh
If Len(strTry) > TopMatch Then TestString strTry
Next N
Fuzzy = TopMatch / CSng(L1)
End Function
And this sub procedure
Quote:
Sub TestString(strIn As String)
Dim L As Integer
Dim strTry As String
Dim iCh As Integer
L = Len(strIn)
If L <= TopMatch Then Exit Sub
strTry = "*"
For iCh = 1 To L
strTry = strTry & Mid(strIn, iCh, 1) & "*"
Next iCh
If strCompare Like strTry Then
If L > TopMatch Then TopMatch = L
End If
End Sub
Re: How to compare text string of two different columns in Excel
Even I was also confused and make the several attempts for creating these Programs but finally I have created a function that will work for this query.
Function FrstLtrs(str As String) As String
Quote:
Dim temp
Dim i As Long
temp = Split(Trim(str))
For i = 0 To UBound(temp)
FrstLtrs = FrstLtrs & Left(temp(i), 1)
Next i
Max
Re: How to compare text string of two different columns in Excel
The above works but there is need to make some changes that you have to modify
Quote:
Function FrstLtrs(str As String) As String
Dim temp
Dim i As Long
temp = Split(Trim(str))
For i = 0 To UBound(temp)
FrstLtrs = FrstLtrs & Left(temp(i), 1)
Next i
End Function
May this will be the correct function that works.