+ Reply to Thread
Results 1 to 8 of 8

Extract State Code from Single Cell

  1. #1
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Extract State Code from Single Cell

    I have a number addresses; each in a single cell. I need to extract the state code from each cell. Every address is formated exactly the same (i.e. the state code occurs before the last space of each address field). Examples are as follows:

    55555 DON JUAN PLACE WOODLAND HILLS CA 91364-6554
    55555 POINTE REGAL CIRCLE APT 4X4 DEL RAY BEACH FL 33484
    12345 SOUTH LAKESHORE DR APT PH0 BROWNS MILLS NJ 08015-4300
    55555 HASSOP LANE BURLESON TX 76028

    Desired output as follows:

    CA
    FL
    NJ
    TX

    Thanks in advance for any comments.

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Extract State Code from Single Cell

    Try this...

    =TRIM(LEFT(RIGHT(SUBSTITUTE(A2," ",REPT(" ",99)),198),99))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Valued Forum Contributor TheCman81's Avatar
    Join Date
    11-06-2012
    Location
    Edinburgh, UK
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    346

    Re: Extract State Code from Single Cell

    One way is this

    =LEFT(REPLACE(A1,1,FIND("|",SUBSTITUTE(A1," ","|",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1)),""),2)
    Excel Guru in the making

    <----------If the question has been answered to your satisfication please click the Add Repuation star to the left

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Extract State Code from Single Cell

    Hi,

    Perhaps:

    =TRIM(MID(A1,1+FIND("|",SUBSTITUTE(A1," ","|",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))-1)),2))

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Extract State Code from Single Cell

    You can use.

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  6. #6
    Valued Forum Contributor
    Join Date
    11-20-2003
    MS-Off Ver
    2010, 2016
    Posts
    1,176

    Re: Extract State Code from Single Cell

    All solutions worked with exception of last one. Fotis, I'm getting an error on formula. It appears the error is occuring on 'Find' portion of the formula. Thanks.

  7. #7
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Extract State Code from Single Cell

    try this
    =TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",LEN(A1))),(SUMPRODUCT((MID(A1,ROW($1:$100),1)=" ")*1)-1)*LEN(A1),LEN(A1)))

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Extract State Code from Single Cell

    All the other solutions work great. Also mine!
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Extract Zip Code from the address in a single cell
    By maacmaac in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-26-2013, 11:29 AM
  2. Data extract by state
    By mathanraj76 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 04-04-2013, 05:24 AM
  3. [SOLVED] GetMatch plus VBA Code to Extract Matched Numbers from 2 Single Cells
    By david gonzalez in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 02-18-2013, 05:08 PM
  4. [SOLVED] city, state, zip from a single cell to multiple cells
    By wjs2002 in forum Excel General
    Replies: 3
    Last Post: 04-29-2005, 02:06 AM
  5. Extract city, state and zip code from a single cell
    By jajoseph@zoominternet.net in forum Excel General
    Replies: 6
    Last Post: 02-06-2005, 10:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1