+ Reply to Thread
Results 1 to 6 of 6

Formula to find and replace where needed

  1. #1
    Registered User
    Join Date
    06-03-2011
    Location
    Florida, USA
    MS-Off Ver
    Excel 2013
    Posts
    46

    Question Formula to find and replace where needed

    Hi, I have a table of data and it includes names in Column A. Sometimes the same people's names are entered a little differently but it is the same person. There are about 10 names where there is a variation in spelling etc. The thing is that in most cases the main letters are together e.g. you may find (dan able, d. able, mr d. able). The same type of thing happens with some other names. I thought of doing a find and replace for *able* and a similar things for others like *don*. There is one name with a comma (,) in the middle (e.g. Mc Dona,ld and Mc Donald and McDonald) but I can replace that manually ahead of time if it complicates things. I want to use one formula or a macro to finds those names in the column and replace the name in the column with one of those in the list if it has the name within it.

    I have attached a spreadsheet to make it clearer.

    I am also copying and pasting the info here in case that's easier for reference:
    BEFORE
    tracy
    tracy's
    dan able
    d. able
    d. able
    McDona,ld
    McDonald
    Mc Donald
    Curtis
    Wadsworth


    REFERENCE LIST OF NAMES TO CHANGE TO WHERE THERE ARE MANY VARIATIONS:
    tracy
    able
    McDonald

    RESULT after doing the find and replace formula
    tracy
    tracy
    able
    able
    able
    McDonald (I can change this manually first if McDonald with the spaces and , make it difficult to set up the formula).
    McDonald
    McDonald
    Curtis
    Wadsworth

    Thanks!
    Attached Files Attached Files
    Last edited by maymano; 11-07-2013 at 02:08 PM.

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Formula to find and replace where needed

    hi maymano. i'm not sure if comma is something you always want to remove? if you want to manually check & remove, then do it first before you do:
    =IFERROR(LOOKUP(2*15,SEARCH($C$2:$C$4,A2),$C$2:$C$4),A2)

    if you can don't mind replacing it straight away, then:
    =IFERROR(LOOKUP(2*15,SEARCH($C$2:$C$4,SUBSTITUTE(A2,",","")),$C$2:$C$4),A2)

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Registered User
    Join Date
    06-03-2011
    Location
    Florida, USA
    MS-Off Ver
    Excel 2013
    Posts
    46

    Re: Formula to find and replace where needed

    Hi benishiryo, thanks! The one thing that could be useful to include since we can eliminate the (comma) with the SUBSTITUTE command is to consider eliminating a space in a name where it is not needed. e.g. the third Mc Donald should be McDonald. I assume you would you something like SUBSTITUTE(A9," ","") - is that correct and where would you put it?

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Formula to find and replace where needed

    you're welcome. yes you can slot that inside, after or before substituting the commas:
    =IFERROR(LOOKUP(2*15,SEARCH($C$2:$C$4,SUBSTITUTE(SUBSTITUTE(A2,",","")," ","")),$C$2:$C$4),A2)

    =IFERROR(LOOKUP(2*15,SEARCH($C$2:$C$4,SUBSTITUTE(SUBSTITUTE(A2," ",""),",","")),$C$2:$C$4),A2)

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  5. #5
    Registered User
    Join Date
    06-03-2011
    Location
    Florida, USA
    MS-Off Ver
    Excel 2013
    Posts
    46

    Re: Formula to find and replace where needed

    Hi, yes - the formula does what it is supposed to. I am sorry but I did not ask this before since I had simplified the data but I found it does not work when there is more than one word in the name e.g. John Smith / Jane Smith Jr, John Smith Jr, John Smit,h Jr
    I may chose to make these all John Smith or John Smith Jr in the preferred list.

    also it did not work if i had a Tracy and a Tracy's and I wanted the preferred list to show both as either Tracy or Tracy's. It saw them differently because I assume it did not eliminate the apostrophe first "'". Itried to add in "'","") but it said there are too many arguments.

    Thanks for the help.

  6. #6
    Registered User
    Join Date
    06-03-2011
    Location
    Florida, USA
    MS-Off Ver
    Excel 2013
    Posts
    46

    Re: Formula to find and replace where needed

    I marked this as solved since Benishiryo's did solve what I asked based on the initial data provided.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help Needed with Find and Replace Macro
    By e30325i in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-13-2013, 02:49 PM
  2. VBA Find and replace loop help needed
    By susanbarbour in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-13-2012, 08:43 AM
  3. Formula needed for find and replace multiple lines
    By helloandrew in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2010, 09:29 AM
  4. [SOLVED] FIND and REPLACE characters needed
    By Peter C in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 02-10-2006, 03:10 PM
  5. FIND and REPLACE characters needed
    By Peter C in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-08-2006, 05:20 PM

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