Results 1 to 4 of 4

Thread: How to compare text string of two different columns in Excel

  1. #1
    Join Date
    Dec 2011
    Posts
    64

    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.

  2. #2
    Join Date
    May 2011
    Posts
    523

    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
    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

    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

  3. #3
    Join Date
    May 2011
    Posts
    410

    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

    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

  4. #4
    Join Date
    Jun 2011
    Posts
    798

    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
    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.

Similar Threads

  1. Find the number of text repeated in columns of Excel
    By Jigisha in forum MS Office Support
    Replies: 4
    Last Post: 24-02-2012, 04:35 PM
  2. Replies: 2
    Last Post: 15-02-2012, 08:17 PM
  3. My Text are overlapping with other columns in Excel
    By RajiI in forum MS Office Support
    Replies: 4
    Last Post: 27-01-2012, 07:20 PM
  4. How to compare two Date values in two different columns of a table
    By Ehtesham SIddiqui in forum Windows Software
    Replies: 1
    Last Post: 06-10-2011, 11:32 AM
  5. How to compare two columns from different worksheet
    By Ameya in forum Windows Software
    Replies: 3
    Last Post: 27-04-2009, 11:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,488,005.33848 seconds with 17 queries