Results 1 to 35 of 35

Compare Two Cells & Return Whats Common Between the two strings and delete the variation

Threaded View

alfykunable Compare Two Cells & Return... 04-04-2012, 04:21 AM
Andrew-R Re: Compare Two Cells &... 04-04-2012, 04:48 AM
alfykunable Re: Compare Two Cells &... 04-04-2012, 08:45 AM
babuvi151 Re: Compare Two Cells &... 12-15-2013, 02:12 PM
k.gourav1261 Re: Compare Two Cells &... 08-20-2018, 07:44 AM
BRISBANEBOB Great work 07-20-2020, 06:11 PM
kishore verma Re: Compare Two Cells &... 10-22-2020, 05:10 AM
kishore verma Re: Compare Two Cells &... 10-22-2020, 05:23 AM
Andrew-R Re: Compare Two Cells &... 04-04-2012, 08:52 AM
alfykunable Re: Compare Two Cells &... 04-04-2012, 01:32 PM
Andrew-R Re: Compare Two Cells &... 04-04-2012, 03:29 PM
alfykunable Re: Compare Two Cells &... 04-12-2012, 04:15 AM
Andrew-R Re: Compare Two Cells &... 04-12-2012, 04:33 AM
alfykunable Re: Compare Two Cells &... 04-12-2012, 04:50 AM
Andrew-R Re: Compare Two Cells &... 04-12-2012, 05:50 AM
alfykunable Re: Compare Two Cells &... 04-12-2012, 06:44 AM
Andrew-R Re: Compare Two Cells &... 04-13-2012, 03:02 AM
alfykunable Re: Compare Two Cells &... 04-13-2012, 03:36 AM
jindon Re: Compare Two Cells &... 04-13-2012, 05:12 AM
alfykunable Re: Compare Two Cells &... 04-13-2012, 06:48 AM
Rima123 Comparing two text containing... 08-05-2013, 08:12 AM
jindon Re: Compare Two Cells &... 04-13-2012, 09:22 PM
alfykunable Re: Compare Two Cells &... 04-17-2012, 11:43 PM
jindon Re: Compare Two Cells &... 04-18-2012, 12:24 AM
ayeletk Re: Compare Two Cells &... 01-02-2013, 10:55 AM
aliastx Re: Compare Two Cells &... 07-07-2013, 06:04 PM
jindon Re: Compare Two Cells &... 07-07-2013, 06:34 PM
aliastx Re: Compare Two Cells &... 07-08-2013, 11:47 AM
jindon Re: Compare Two Cells &... 07-08-2013, 06:19 PM
aliastx Re: Compare Two Cells &... 07-09-2013, 01:35 PM
Canvasshoes Re: Compare Two Cells &... 10-21-2013, 11:27 AM
jindon Re: Compare Two Cells &... 10-21-2013, 09:43 PM
abousetta Re: Compare Two Cells &... 12-15-2013, 02:17 PM
FDibbins Re: Compare Two Cells &... 08-20-2018, 04:07 PM
JeteMc Re: Compare Two Cells &... 10-24-2020, 02:00 PM
  1. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,835

    Re: Compare Two Cells & Return Whats Common Between the two strings and delete the variati

    Here's my version

    In cell E2

    =IF(C1<>C2,GetMaxCommon(B2,$B$2:$C$51,C2,FALSE),"")

    Then fill down to the bottom of the table

    Function GetMaxCommon(ByVal txt As String, rng As Range _
        , myGroup As Long, CSense As Boolean) As String
        Dim r As Range, x, i As Long, temp As String, m As Object, Pos As Long, n As Long
        Static RegX As Object
        If RegX Is Nothing Then
            Set RegX = CreateObject("VBScript.RegExp")
            RegX.IgnoreCase = Not CSense
        End If
        x = Split(txt)
        Pos = UBound(x)
        For Each r In rng.Columns(1).Cells
            If (r.Value <> txt) * (r(, 2).Value = myGroup) Then
                temp = r.Value
                With RegX
                    For i = 0 To UBound(x)
                        .Pattern = x(i)
                        If .test(temp) Then
                            Set m = .Execute(temp)(0)
                            If m.FirstIndex <> 0 Then
                                n = i - 1
                                Exit For
                            Else
                                temp = Trim(Mid$(temp, m.Length + 1))
                            End If
                        Else
                            n = i - 1
                            Exit For
                        End If
                    Next
                    If Pos > n Then Pos = n
                End With
            End If
        Next
        ReDim Preserve x(Pos)
        GetMaxCommon = Join$(x)
    End Function
    Remove Variation With Function.xlsm
    Last edited by jindon; 04-13-2012 at 06:06 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1