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.
Last edited by freerdj; 08-27-2009 at 05:43 PM.
Spell checker under Review tab?
Regards
Special-K
I rarely return to a problem once I've answered it so make sure you clearly define what the trouble is.
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
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
You could use a UDF.
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.Code:------------A------------ --------------B--------------- C -----D----- ---E--- 1 Location Title Correction Restaurant BStoria 2 Astoria Restaruant Inc BStoria Restaurant Inc Resta Astoria 3 Beauvais Caribbean Restau Beauvais Caribbean Restaurant Restaraunt 4 Bedford Springs Resort Bedford Springs Resort Restaruant 5 Beijing Restaruant Beijing Restaurant Restau 6 Bella Luna Pizzeria Resta Bella Luna Pizzeria Restaurant Restauarant 7 Bernardo's Mexican Resta Bernardo's Mexican Restaurant Restauarnt 8 Bershes Family Restauarnt Bershes Family Restaurant Restaur 9 Billy Joes Restaraunt Billy Joes Restaurant Restaurnte 10 Blue Jeans Lounge & Resta Blue Jeans Lounge & Restaurant 11 Boothbay Harbor Inn Resta Boothbay Harbor Inn Restaurant
The formula in B2 and down is
=WordSubstitute(A2, $D$1:$E$9)
The UDF is
Code:Function WordSubstitute(ByVal sInp As String, r As Range) ' The top row of r contains replacement words for the words below Dim rCol As Range Dim cell As Range Dim sFind As String Dim sRepl As String sInp = " " & WorksheetFunction.Trim(sInp) & " " For Each rCol In r.Offset(1).Resize(r.Rows.Count - 1).Columns sRepl = " " & rCol.Cells(0).Text & " " For Each cell In rCol.Cells sFind = " " & cell.Text & " " If Len(Trim$(sFind)) = 0 Then Exit For If InStr(1, sInp, sFind, vbTextCompare) Then sInp = Replace$(sInp, sFind, sRepl, , , vbTextCompare) Exit For End If Next cell Next rCol WordSubstitute = Mid$(sInp, 2, Len(sInp) - 2) End Function
Last edited by shg; 08-29-2009 at 04:05 PM. Reason: renamed, tweaked
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
You are welcome...
...Note that this is not 100% foolproof...
If you have a spelling like Ristorante then it will not get fixed...
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
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...
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
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..
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
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.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks