Remove City and US state codes from an address string

Joined
Jun 26, 2017
Messages
7
Hi all,

I am new in this forum and also new in my programming career in spreadsheets. I have a thousands of US addresses strings from which I have to separate the home number and street name, the city, the State code, and then the postal code.
Here are three examples:

713 Arch Street, Jacksonville Beach, FL 32250
341 Cardinal Drive, Wethersfield, CT 06109
134 Main Street East, Anchorage, AK 99504

a) For the Home number and street name, I'm ok with this formula: =MID(A6,1, FIND(",", A6,1)-1)

But I cannot find the formula to remove the cities and the postal codes.


Please help me

Regards,Olivier.

<colgroup><col width="363" style="width:272pt"> </colgroup><tbody>
</tbody>

<colgroup><col width="363" style="width:272pt"> </colgroup><tbody>
</tbody>



<colgroup><col width="363" style="width:272pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Welcome to the forum.

These kind of problems are notorious for being difficult due to variations in the input data. If all your data looks like your examples, these might work:

ABCDEF
1Street addressCityStateZIP
2713 Arch Street, Jacksonville Beach, FL 32250713 Arch StreetJacksonville BeachFL32250
3341 Cardinal Drive, Wethersfield, CT 06109341 Cardinal DriveWethersfieldCT06109
4134 Main Street East, Anchorage, AK 99504134 Main Street EastAnchorageAK99504

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet4

Worksheet Formulas
CellFormula
C2=LEFT(A2,FIND(",",A2)-1)
D2=TRIM(LEFT(SUBSTITUTE(MID(A2,LEN(C2)+2,LEN(A2)),",",REPT(" ",LEN(A2))),LEN(A2)))
E2=MID(A2,LEN(A2)-7,2)
F2=RIGHT(A2,5)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



Any slight variations could throw them off though.

Hope this helps.
 
Upvote 0
Hi Eric,

Thank you very much for your help. The second formula doesn't work. Please, help me to fix the problem
=TRIM(LEFT(SUBSTITUTE(MID(A2,LEN(C2)+2,LEN(A2)),",",REPT(" ",LEN(A2))),LEN(A2)))

Best,

Olivier
 
Upvote 0
Sir Eric,

I'm sorry the formula works perfectly. I did a wrong entry. I put in my formula LEN(C2)+2 instead of LEN(B2)+2.

Thank you very much for you suport

Olivier
 
Upvote 0
Worksheet Formulas
CellFormula
D2=TRIM(LEFT(SUBSTITUTE(MID(A2,LEN(C2)+2,LEN(A2)),",",REPT(" ",LEN(A2))),LEN(A2)))

<tbody>
</tbody>

<tbody>
</tbody>
Since there will be calculated values in Columns C, E and F, you should also be able to use this simpler formula in cell D2...

=MID(A2,LEN(C2)+3,LEN(A2)-LEN(C2)-12)

Same caution about any variations in the structure of the inputted values as you posted.
 
Last edited:
Upvote 0
Bi Yoro Olivier ZOUZOU: Glad we could help! :)

Rick: Good point! I worked out the formulas from left to right. I should have gone back to simplify D2.
 
Upvote 0
Hello Everyone,

Please, I need help with this SUMIF FUNCTION. I have a spreadsheet with 1000 items sold in column A and the hour of sale in column D. I am asked to find the total number of items sold after 3PM.In column B I have the price of each item and in column C I have the date of sale of the corresponding item.

I used the following formula: = =SUMIF(A:A, ">3PM",D:D)=549.62

I found a result with decimal. However, there is no decimal in the number of items sold. Since column A (1000 items) represents the items sold. from a part has been sold after 3PM.

Help, please

Olivier
 
Upvote 0
For future reference, if you have a significantly different question, you should open a new topic.

Next, you want COUNTIF:

ABCDEF
1Item Price DateTimeItems sold after 3 PM
2Pencil $ 1.00 1-Jan11:00:00 AM3
3Pen $ 1.95 1-Apr1:49:00 PM
4Notebook $ 2.50 6-May3:01:00 PM
5Mouse $ 12.95 21-Jun5:45:00 PM
6Car $ 10,000.87 23-Jun9:21:00 PM

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet8

Worksheet Formulas
CellFormula
F2=COUNTIF(D:D,">"&TIMEVALUE("3:00 PM"))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



If the time values in D are stored as Excel times, and not text, then Excel stores them as a fraction. .25 = 6 AM, .75 = 6 PM, etc. You can use .625 in the formula for 3 PM if you like, but using TIMEVALUE (or TIME) makes it much more readable.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,560
Members
449,089
Latest member
Motoracer88

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