+ Reply to Thread
Results 1 to 12 of 12

Replace bad names from a list of good names

  1. #1
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Replace bad names from a list of good names

    Hi Again,

    Can someone help me create a script that will replace the names in column A on sheet1 from a Master sheet in the same workbook?

    The problem is that different users are entering data on sheet1 col A in different ways example someone may enter Johnc or John C Or John What I want is for something to run down col A on sheet1 and look for the like name on the master sheet if the name matches then do nothing but if the name is like another name on the master sheet then replace the name if they are almost alike.

    Anyway to do that?


    Thanks as always!!!
    Mike

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Replace bad names from a list of good names

    Hi, It the list on the Master sheet just one name ??
    Regards Mick
    Last edited by MickG; 05-14-2009 at 11:04 AM.

  3. #3
    Registered User
    Join Date
    01-22-2009
    Location
    Chicago
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Replace bad names from a list of good names

    I have a similar situation where I convert truncated resource names to full length names.

    I use two sets of arrays where the truncated value and desired value share the same positions in their respective arrays, eg... array(n). You just use a loop to cycle through the list until you find a match.

    But like Mickg said, you need a definitive list of values to compare with on both sides.

  4. #4
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Replace bad names from a list of good names

    Quote Originally Posted by MickG View Post
    Hi, It the list on the Master sheet just one name ??
    Regards Mick
    Yes just one name unless there is two John's example if there were two John's they would be John A and John B Other wise the list is just the first name.

    Thank You, Mike

  5. #5
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Replace bad names from a list of good names

    Hi, Try this:-
    I assumed that the "Names" where in column "A" of both sheets.
    Please Login or Register  to view this content.
    Regards Mick

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Replace bad names from a list of good names

    Once you get that fixed, make a NAMED RANGE out of your master list of correct names and put a Data > Validation > List using that named range into column A where they are entering names. This will give your users a drop down box to choose names from...or they can still type, but if they type a wrong version, it won't stay, they'll have to correct it.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  7. #7
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Replace bad names from a list of good names

    Quote Originally Posted by MickG View Post
    Hi, Try this:-
    I assumed that the "Names" where in column "A" of both sheets.
    Please Login or Register  to view this content.
    Regards Mick
    Hi Mick, Thanks for your help, However I was unable to get this to work, I mean the script runs without any errors but wont change the names on sheet1 from the Master Sheet.

    I was just hoping I didn't have to run through half the years data correcting peoples names. But that may be the easiest thing to do at this point.

    JBeaucaire you are correct I have already done the change a couple weeks back with your suggestion on the validation. I should not have the problem going forward. It was just the first few months of data I needed to correct. I was hoping for a short cut...

    Thanks Guys for trying. Mike

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Replace bad names from a list of good names

    Hi, Can you attach you workbook (.xls) or a trial version.
    Regards Mick

  9. #9
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Replace bad names from a list of good names

    Quote Originally Posted by MickG View Post
    Hi, Can you attach you workbook (.xls) or a trial version.
    Regards Mick
    Sure, Here is an example.

    Thank You, Mike
    Attached Files Attached Files

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Replace bad names from a list of good names

    Hello realniceguy5000,

    This macro appears to work correctly. Check it out on a copy of the actual data to be sure. A button has been added to Sheet1 to run the macro.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  11. #11
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Replace bad names from a list of good names

    Hi, This does'nt resolve the immediate problem, but it might be a solution.
    On sheet "Master" there is a Button, and when clicked will colour all the cells in column "A" sheet (1) that Match the Names in sheet "Master". you could then alter the Incorrect Ones.
    On sheet(1) there is a "SelectionChange Event" that will stop the incorrect entry of a name in column "A" that does not match one of the Sheet "Master" names. The code will show a Msgbox , Telling you the name is Incorrect and the Name will then be deleted.
    This is about the best I can do. I think the original Problem could be sorted with a some alterations to the "Master" Sheet of names.
    Regards Mick
    Ps :- I've just seen Leith might have solved you problem !!
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor realniceguy5000's Avatar
    Join Date
    03-20-2008
    Location
    Fl
    MS-Off Ver
    Excel 2003 & 2010
    Posts
    951

    Re: Replace bad names from a list of good names

    Thanks Guys. We are much further than before let me plug this into some real data. However it appears on the test book that it is working.

    Thanks Again, Mike

+ 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