+ Reply to Thread
Results 1 to 1 of 1

Compare two text cells and extract common text words

  1. #1
    Registered User
    Join Date
    11-21-2012
    Location
    Delhi
    MS-Off Ver
    Excel 2007
    Posts
    6

    Exclamation Compare two text cells and extract common text words

    Hi all,

    I have a worksheet containing addresses in column A and B to compare, I need to compare address of A1 to B1 cell particularly and have to check if the:
    Address is same of A1 and B1 cell then Outcome- True
    Address is partial common of A1 and B1 cell then Outcome- common words of both cell A1 and B1
    Address is not matching of A1 and B1 cell then Outcome- False.

    For example:

    A1: 399,SADAR BAZAR,JHANSHIMR. RADHA MOHAN AGRAWAL,PH-0517-2472580,9839214980
    B1: 399,SADAR BAZAR,JHANSHIMR

    Outcome (c1): . 399,SADAR BAZAR,JHANSHIMR

    A1: UMA SHANKAR SINGH, GHAZIPUR VILLAGE TARANPUR,POST JUNGIPUR
    B1: VILLAGE TARANPUR,POST JUNGIPUR, GHAZIPUR SHANKAR, Uttar Pradesh

    Outcome (C1): VILLAGE TARANPUR,POST JUNGIPUR, GHAZIPUR SHANKAR

    For the example am attaching original sheet named sample;

    I have already post this question earlier and only one gentleman StephenR replied with this code:

    Function x(v1 As Variant, v2 As Variant) As String

    Dim i As Long, j As Long, w1, w2, s As String

    w1 = Split(v1, ",")
    w2 = Split(v2, ",")

    For i = LBound(w1) To UBound(w1)
    For j = LBound(w2) To UBound(w2)
    If Trim(w1(i)) = Trim(w2(j)) Then
    s = s & ", " & Trim(w1(i))
    Exit For
    End If
    Next j
    Next i

    x = Mid(s, 3)

    End Function



    although the formula is working fine but there are still some cases where the output is null even the address are partially matching; you can check these cases after putting the function in given Example file... filter the blank field please.

    Example:
    A1: Hazi refik 9336644848 Plot No.49 Roti Godam Sitapur SITAPUR
    B1: Plot No.49 Roti Godam Sitapur SITAPUR

    Outupt: Null

    required outupt: Plot No.49 Roti Godam Sitapur SITAPUR

    I want any common text, numbers., signs... whatever is common in both cells as an outcome in desired cell, what i need is to compare a text with another text... and extract the common text.

    Now i would like you to please write a module to help this out.

    I have 1000's of these kind of rows to be compared, I hope any of you can give me a hand on this, thanks :-)
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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