Text String Variable Length

masonbp2

New Member
Joined
Jul 27, 2017
Messages
15
I am having an issue extracting data from a column that I have. I need the city of the customer in a new column. The column that I already have is as so:

[TABLE="width: 340"]
<tbody>[TR]
[TD="width: 340"]US315310 - SENSICAL SOLON OH
[TABLE="width: 340"]
<tbody>[TR]
[TD="width: 340"]US318310 - DKM-AD ART BUFFALO NY[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
US500190 - STANDARD RUBBER PRODUCTS CO ELKGROVE VILLAGE IL
[TABLE="width: 340"]
<tbody>[TR]
[TD="width: 340"]US525260 - CORTAPE INC CUYAHOGA FALLS OH

I would like to have the results as below

Solon [/TD]
[/TR]
[TR]
[TD="width: 340"]Buffalo [/TD]
[/TR]
</tbody>[/TABLE]
ELkgrove Village
Cuyahoga Falls

Obviously the sole use of left right and mid don't work here as the number of digits is always varying.
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I don't see any easy way to do it (or difficult way for that matter)
Given the possibility of multi-word Cities.

It would be fairly easy if we could say it's always the 2nd to last word in the string (the state abbreviation is the last).
But with cities of 2 or more words, that's not doable.

Do you have, or can you create a list of either:
All possilble cities
Or
All possible Company Names
 
Upvote 0
Not unless I try and brute force a list but at that point I might as well just do the columns individually. The issue is further complicated in that some companies have more than one city.
Thanks for taking a look though
 
Upvote 0
Do you have any control or input over the source data?
Can a delimiter be added to the source data, like a semicolon after company name, and after the city ?

US315310 - SENSICAL; SOLON; OH[TABLE="class: cms_table, width: 340"]
<tbody>[TR]
[TD="width: 340"]US318310 - DKM-AD ART; BUFFALO; NY[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
The data is sourced from IBM Cognos so to the best of my knowledge I don't believe that is an option.
 
Upvote 0
Jonmo1,

I have figured out a way to attain a list of all possible cities. How would you recommend proceeding?
 
Upvote 0
With your list of all possible cities in say G1:G10
And the original string in A1

=LOOKUP(2^15,SEARCH($G$1:$G$10,A1),$G$1:$G$10)

Important, there cannot be any blanks in your list of cities.
 
Upvote 0

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top