I have a workbook with two tabs. My first tab has rows added to it by various people everyday, and one cell entered is a city name. Everybody enters this city name different, for example, New York could be entered as NYC, NY, NwYrk, New York, NewYkCty, etc. On a second tab, I have created a 'lookup' database where Row 2 is the proper way to spell the City name, and every time I see a new iteration of how somebody spells it I copy their version below it. I am looking for a formula or a way in VBA to be able to iterate through the thousands of rows I can get within a month against the thousands of city names I have in my mini-database and provide to me which column number the match is found in, so I can run offset formulas from it. One more thing to note, prior day locations can be edited so I will need to have this always updating if a change has been made to the city name.
I have tried this code below, but it takes 5-8 minutes to run through every single cell and continues to take longer as more cells get added.
With Sheets("Billings").Range("b1")
Set columnLocationList = Range(.Offset(1, 0), .End(xlDown))
End With
For Each columnLocations In columnLocationList
For Each locations In Sheets("Database Names").UsedRange
If columnLocations = locations Then
columnLocations.Offset(0, 1).Value = locations.Column
GoTo nextBill
End If
Next locations
nextBill:
Next columnLocations
Tab: Billings
ID | City Name | Column Number |
---|---|---|
1 | NYC | 3 |
2 | LAX | 2 |
Tab: Database Names
City Names | Los Angeles | New York |
---|---|---|
Entered Names | LA | NC |
LAX | NYC |