+ Reply to Thread
Results 1 to 16 of 16

Replacing Misspelled sub-string in varying full string

  1. #1
    Registered User
    Join Date
    06-04-2009
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Replacing Misspelled sub-string in varying full string

    I have a situation where a word (in this case "Restaurant") is misspelled in a list of about 78,000 location names. The location names are in one column, and the [misspelled] word "Restaurant" is anywhere between the first word of the string, to the last, with any amount of alphanumeric/symbol characters between. For example:

    Alice's Restaurant
    Alli's Restaurant & Bar
    Alexis Restaurant of Waukesha
    Amigo's Mexican Restaurant #2

    I want to replace any misspellings of the word with correct, but since the list is so long, and the way the word is misspelled varies so much, going through manually is entirely too time-consuming.

    Some of the variations I've seen so far are Resta, Restau, Restaur, Restuara, etc...

    Is there a way to search and replace cells that contain the text in any location of the string? Specifically, where ever there is JUST "Restau", replace with "Restaurant", regardless of where it is in the string? This way, trailing text is not deleted or manipulated, i.e. "Alice's Restaur and Bar" will change to "Alice's Restaurant and Bar".

    There are many misspelled words in this list, but the most ubiquitous is Restaurant, so any help with this would be extremely helpful. Thanks.
    Attached Files Attached Files
    Last edited by freerdj; 08-27-2009 at 04:43 PM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Replacing Misspelled sub-string in varying full string

    Spell checker under Review tab?
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Replacing Misspelled sub-string in varying full string

    Try this to replace anything that starts with "Rest" with "Restaurant"

    =REPLACE(A1,SEARCH("Rest",A1),SEARCH(" ",MID(A1,SEARCH("Rest",A1),255))-1,"Restaurant")

    adjust A1 to suit your original string
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Replacing Misspelled sub-string in varying full string

    Quote Originally Posted by Special-K View Post
    Spell checker under Review tab?
    Restaurant wasn't offered when checking Restau and other trimmings...

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Replacing Misspelled sub-string in varying full string

    You could use a UDF.
    Please Login or Register  to view this content.
    The D:E range at right has the correct spelling in the top row, and misspellings below for all the words you want to correct. Col E changes Astoria to BStoria just as an example. You can make the range as wide as needed.

    The formula in B2 and down is

    =WordSubstitute(A2, $D$1:$E$9)

    The UDF is
    Please Login or Register  to view this content.
    Last edited by shg; 08-29-2009 at 03:05 PM. Reason: renamed, tweaked
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    06-04-2009
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Replacing Misspelled sub-string in varying full string

    Quote Originally Posted by NBVC View Post
    Try this to replace anything that starts with "Rest" with "Restaurant"

    =REPLACE(A1,SEARCH("Rest",A1),SEARCH(" ",MID(A1,SEARCH("Rest",A1),255))-1,"Restaurant")

    adjust A1 to suit your original string

    I intentionally misspelled my cell to "Cozumel Mexican Restarant" and applied the function to it and it returned a value error.

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Replacing Misspelled sub-string in varying full string

    Quote Originally Posted by freerdj View Post
    I intentionally misspelled my cell to "Cozumel Mexican Restarant" and applied the function to it and it returned a value error.
    Sorry...didn't account for it being the last word...

    Try:

    =REPLACE(A1,SEARCH("Rest",A1),SEARCH(" ",MID(A1,SEARCH("Rest",A1),255)&" ")-1,"Restaurant")

  8. #8
    Registered User
    Join Date
    06-04-2009
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Replacing Misspelled sub-string in varying full string

    Quote Originally Posted by NBVC View Post
    Sorry...didn't account for it being the last word...

    Try:

    =REPLACE(A1,SEARCH("Rest",A1),SEARCH(" ",MID(A1,SEARCH("Rest",A1),255)&" ")-1,"Restaurant")

    The misspell is not always the last word; will this function apply to other variations as well?

    shg --> I will apply the UDF and try shortly

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Replacing Misspelled sub-string in varying full string

    Quote Originally Posted by freerdj View Post
    The misspell is not always the last word; will this function apply to other variations as well?
    Yes, it will work as long as the part string "Rest" or "rest" is there.

  10. #10
    Registered User
    Join Date
    06-04-2009
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Replacing Misspelled sub-string in varying full string

    Quote Originally Posted by NBVC View Post
    Yes, it will work as long as the part string "Rest" or "rest" is there.
    I wish you could somehow see the excitement and cheers that are flowing through our office right now.

    This will save us days of manual searching since we can apply it elsewhere.

    Thank you SO much.

    And thank you shg for the UDF

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Replacing Misspelled sub-string in varying full string

    You are welcome...

    ...Note that this is not 100% foolproof...

    If you have a spelling like Ristorante then it will not get fixed...

  12. #12
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Replacing Misspelled sub-string in varying full string

    If this might be the case, then after you applied the 1st phase, copy that new column and paste special, selecting Values, over the original or over itself (remember to maintain a backup in case of disaster)... Then apply formula like

    =IF(ISNUMBER(SEARCH("Rist",A1)),REPLACE(A1,SEARCH("Rist",A1),SEARCH(" ",MID(A1,SEARCH("Rist",A1),255)&" ")-1,"Restaurant"),A1)

    this will leave the correct ones alone and fix the ones with Rist in it...

    You can repeat this again and again to get any subtleties you may encounter...

  13. #13
    Registered User
    Join Date
    06-04-2009
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Replacing Misspelled sub-string in varying full string

    Quote Originally Posted by NBVC View Post
    If this might be the case, then after you applied the 1st phase, copy that new column and paste special, selecting Values, over the original or over itself (remember to maintain a backup in case of disaster)... Then apply formula like

    =IF(ISNUMBER(SEARCH("Rist",A1)),REPLACE(A1,SEARCH("Rist",A1),SEARCH(" ",MID(A1,SEARCH("Rist",A1),255)&" ")-1,"Restaurant"),A1)

    this will leave the correct ones alone and fix the ones with Rist in it...

    You can repeat this again and again to get any subtleties you may encounter...

    Understood. There are several incorrect versions of "Grill", "Family", "Lounge", "Country Club", etc...

    Although there's no way I could duplicate this function combo, I do understand that search of "Rest" and replacement of "Restaurant" where found.

    Thanks again, so much.

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Replacing Misspelled sub-string in varying full string

    Maybe shg's UDF is something to look into.. I am sure you can expand the D:E columns to include more fixes and other words....

    so in D1, you have Restaurant and below all possible mispellings, in E1, you have Grill and below all possible misspellings, in F1 you have Lounge and below... well, you get it..

    and then adjust Formula: =ReSpell(A2, $D$1:$E$9) to the full range of words to check for and corrections..

  15. #15
    Registered User
    Join Date
    06-04-2009
    Location
    Virginia
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Replacing Misspelled sub-string in varying full string

    The difference is that I'd have to know all possible misspells of each word in order to correct them, and I'm always discovering new ones.

    The function you provided at least lets me ensure most of the word is searched for.

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Replacing Misspelled sub-string in varying full string

    and I'm always discovering new ones
    Just add them to the list, and make the range taller than necessary (whole columns, perhaps). It quits in each column when it gets to a blank cell.

+ Reply to Thread

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