Solved

Pull City out of Address Cell

Posted on 2013-05-19
2
483 Views
Last Modified: 2013-05-20
I have column of address in the format:

Street Address, City, State such as:

10675 Scripps Poway Pkwy, San Diego, CA

In Column e I need just the city (everything in between the two columns.)
0
Comment
Question by:cansevin
2 Comments
 
LVL 10

Assisted Solution

by:ecarbone
ecarbone earned 250 total points
Comment Utility
Assuming your list of complete addresses start in cell D1, copy/paste this formula into cell E1:

=TRIM(LEFT(RIGHT(SUBSTITUTE(D1,",",REPT(" ",100)),200),100))

Once you past the cell into E1, you can copy/paste that formula all the way down the column. Excel will automatically put in the next cell reference (E2, E3, E4, and so on)

Finally... after you verify that column E contains your cities, you can extract the actual values by doing this:

1. Click once on the 'E' in column E. This selects the entire column
2. Press Control-C to copy the entire column into your clipboard
3. Right-click on Column F (assuming it is empty) and select Paste | Values

Now column F will contain the actual value (city name) instead of a formula.
0
 
LVL 49

Accepted Solution

by:
Gustav Brock earned 250 total points
Comment Utility
In your query you can use:

SELECT
  Mid([YourField],1,InStr([YourField],",")-1) AS Address,
  Mid(Mid([YourField],InStr([YourField],",")+1),1,InStr(Mid([YourField],InStr([YourField],",")+1),",")-1) AS City
FROM YourTable;

/gustav
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now