Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a Text Formula....Easy (Hopefully) 1

Status
Not open for further replies.

rhoneyfi

MIS
Apr 8, 2002
200
US
I have a very large Excel Spreadsheet that has the names and addresses of our clients. The "Address" field contains the city, state, and zip all in the one field. I need to split this field so that the City, State, and Zip are in there own seperate new fields called "City", "State" and "Zip". Any ideas how to do this?? Thanks
 
Hi, are the City, State & Zip seperated in the string and if they are is it with a space or comma.
 
Try these formulas. I assume that your string is in cell AI.

For City use:
=LEFT(A1,FIND(" ",A1)-1)

For State Use:
=IF(ISERR(MID(A1,FIND(" ",A1)+1,IF(ISERR(FIND(" ",A1,FIND(" ",A1)+1)),FIND(" ",A1),FIND(" ",A1,FIND(" ",A1)+1))-FIND(" ",A1)-1)),"",MID(A1,FIND(" ",A1)+1,IF(ISERR(FIND(" ",A1,FIND(" ",A1)+1)),FIND(" ",A1),FIND(" ",A1,FIND(" ",A1)+1))-FIND(" ",A1)-1))

For Zip use:
=RIGHT(A1,LEN(A1)-FIND("*",SUBSTITUTE(A1," ","*",LEN(A1)-LEN(SUBSTITUTE(A1," ","")))))

If you have a 'comma' seperating the elements of the string then substitute " " with "," (ie no spaces).

I hope that this helps you.



 
Alternate,...

Highlite the col

then from menu

Data>text to columns....follow the wizard from there.


also if you run the macro recorder during this process, you will have generated the code needed to do this.

alt+f11 to view after you stop the process
 
I agree with ETID. The text to columns would be the easiest way to go about it.

Brian
USAF
Network +, Win2k Pro
 
Well done ETID,

I have used left, right & len before but your solution suits my needs.

Peter

Remember- It's nice to be important,
but it's important to be nice :)
 
Thanks for all the help everyone! The Data --> Text to Columns worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top