Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Column A has Bob Fred Tom
Column B has Tom Bob Fred I would like to match and identify someway Column A has Bobby Fred Tom Column B has Fred Tom Bob That is not a match I use vlookup to get exact matches. How to get matches if word order is different? |
#2
![]() |
|||
|
|||
![]()
How about this.
Sort the data in each cell in each column. Then compare those sorted cells. I'd insert two new columns that would hold that sorted string. (say C and D) then put a formula like: =sortthecell(a1) in C1 and drag down =sortthecell(b1) in D1 and drag down But now you'll need something that will actually sort the contents of the cell. Depending on your version of excel, you can use this: (for xl2k or higher): Option Explicit Function SortTheCell(rng As Range) As String Dim mySplit As Variant Dim Temp As String Dim iCtr As Long Dim jCtr As Long Dim myStr As String Set rng = rng(1) mySplit = Split(rng.Value, " ") For iCtr = LBound(mySplit) To UBound(mySplit) - 1 For jCtr = iCtr + 1 To UBound(mySplit) If LCase(mySplit(iCtr)) LCase(mySplit(jCtr)) Then Temp = mySplit(iCtr) mySplit(iCtr) = mySplit(jCtr) mySplit(jCtr) = Temp End If Next jCtr Next iCtr SortTheCell = Join(mySplit, " ") End Function or both these (xl97): Option Explicit Function SortTheCell(rng As Range) As String Dim mySplit As Variant Dim Temp As String Dim iCtr As Long Dim jCtr As Long Dim myStr As String Set rng = rng(1) mySplit = Split97(rng.Value, " ") For iCtr = LBound(mySplit) To UBound(mySplit) - 1 For jCtr = iCtr + 1 To UBound(mySplit) If LCase(mySplit(iCtr)) LCase(mySplit(jCtr)) Then Temp = mySplit(iCtr) mySplit(iCtr) = mySplit(jCtr) mySplit(jCtr) = Temp End If Next jCtr Next iCtr myStr = "" For iCtr = LBound(mySplit) To UBound(mySplit) myStr = myStr & " " & mySplit(iCtr) Next iCtr SortTheCell = Mid(myStr, 2) End Function 'from Tom Ogilvy Function Split97(sStr As String, sdelim As String) As Variant Split97 = Evaluate("{""" & _ Application.Substitute(sStr, sdelim, """,""") & """}") End Function ========== If you're new to macros, you may want to read David McRitchie's intro at: http://www.mvps.org/dmcritchie/excel/getstarted.htm Short course: Open your workbook. Hit alt-f11 to get to the VBE (where macros/UDF's live) hit ctrl-R to view the project explorer Find your workbook. should look like: VBAProject (yourfilename.xls) right click on the project name Insert, then Module You should see the code window pop up on the right hand side Paste the code in there. Now go back to excel. Into a test cell and type: =sortthecell(a1) ======== After you have these two helper columns of sorted values, you can use some of the techniques at Chip Pearson's to find your duplicates: http://www.cpearson.com/excel/duplicat.htm LEsa wrote: Column A has Bob Fred Tom Column B has Tom Bob Fred I would like to match and identify someway Column A has Bobby Fred Tom Column B has Fred Tom Bob That is not a match I use vlookup to get exact matches. How to get matches if word order is different? -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Combining & formatting cells with text - Excel 2002 | Excel Discussion (Misc queries) | |||
I want Excel to allow cells with formulas and unrelated text | Excel Discussion (Misc queries) | |||
Format text across cells | New Users to Excel | |||
how do i add the same text after current text in multiple cells | Excel Discussion (Misc queries) | |||
Convert data of cells to any type: Number, Date&Time, Text | Excel Discussion (Misc queries) |