+ Reply to Thread
Results 1 to 14 of 14

Formula to copy and paste the only occurence of 2 characters together

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438

    Formula to copy and paste the only occurence of 2 characters together

    I would like a Formula to copy and paste the only occurence of 2 characters together. Heres an example

    In cell B2 I have

    Baltimore, MD - NPB

    I would like to paste just the MD in cell D2.

    In other words, I just want to extract the state and put the state into cell D2.

    Thanks much in advance.

  2. #2
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Following should be OK ...provided your data structure is consistent ...

    =MID(B2,FIND(",",B2,1)+2,2)
    HTH
    Carim

  3. #3
    Forum Contributor
    Join Date
    07-13-2006
    Posts
    400
    Quote Originally Posted by duugg
    I would like a Formula to copy and paste the only occurence of 2 characters together. Heres an example

    In cell B2 I have

    Baltimore, MD - NPB

    I would like to paste just the MD in cell D2.

    In other words, I just want to extract the state and put the state into cell D2.

    Thanks much in advance.
    is it always after the ","?
    *edit* damns yous carim!! lol

    =MID(B2,FIND(",",B2,1)+2,2)

    if not it'll be a bit uglier

  4. #4
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438
    No, data can be different, sometimes comma space state, sometimes comma state. For example, I tried that formula on another one. Here it is.


    Duluth,MN-CA

    result N-

    Any suggestions?

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    ... manual adjustments ... depending on how many lines you are dealing with ...
    unless you can come up with a limited number of different types ...

    Carim

  6. #6
    Forum Contributor
    Join Date
    07-13-2006
    Posts
    400
    Quote Originally Posted by duugg
    No, data can be different, sometimes comma space state, sometimes comma state. For example, I tried that formula on another one. Here it is.


    Duluth,MN-CA

    result N-

    Any suggestions?
    i think you're going to have to go the macro route.
    that duluth,MN-CA is also gonna give a bit of a problem since MN and CA both are two characters together....sorry i'm not from the states what is the CA representing?

  7. #7
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438
    The CA is a coding system I use for a specific location in MN. I should've noted that I only want the 2 characters after the comma and not any other 2 characters.

  8. #8
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    If your whole data has the coherence you are describing ...

    =TRIM(MID(B2,FIND(",",B2,1)+1,FIND("-",B2,1)-FIND(",",B2,1)-1))
    For these problems, consistency of data structure is key ...

    HTH
    Carim

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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