+ Reply to Thread
Results 1 to 14 of 14

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

  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 ...

    Please Login or Register  to view this content.
    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 ...

    Please Login or Register  to view this content.
    For these problems, consistency of data structure is key ...

    HTH
    Carim

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

    Thanks much! That worked great! Can you tell me the formula to extract all data up to but not including the first comma in a cell?

    For example, in C2, I have the following data

    Anchorage,AK-SSA

    I would like a formula to show just

    Anchorage

    in D2.

    Thanks again

  10. #10
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    You 'd rather have me do it ...
    despite the fact you now have all the elements to be totally independent ...
    lol ... !!!

    Please Login or Register  to view this content.
    HTH
    Carim

  11. #11
    Valued Forum Contributor
    Join Date
    04-11-2006
    MS-Off Ver
    2007
    Posts
    438
    Thanks, that worked too. I don't really know how to program yet, I want to learn though! If I did know even the basics, I'd know how to manipulate the formula you gave me the first time, but I really don't.

    Like "Mid" for example, I assume that Mid means middle of the cell?

    Whatever it is thanks again for the help.

  12. #12
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Yes ...
    Mid() stands for middle ...

    But Try, Test, read Help , ask questions to the forum ...
    and you will soon turn yourself into an expert ... !!!

    HTH
    Carim

  13. #13
    Forum Contributor
    Join Date
    07-13-2006
    Posts
    400
    Quote Originally Posted by duugg
    Thanks, that worked too. I don't really know how to program yet, I want to learn though! If I did know even the basics, I'd know how to manipulate the formula you gave me the first time, but I really don't.

    Like "Mid" for example, I assume that Mid means middle of the cell?

    Whatever it is thanks again for the help.
    easiest way to get to know what a formula does is to type it into a cell and read the description
    i.e.
    type "=mid("
    and it'll give you a tooltip like thing explaining what field it's looking for, then when you put a comma it'll move to the next field.
    you can also click on the equals sign on the formula bar and it'll give an even more in-depth description
    --Mark

    Quantum materiae materietur marmota monax si marmota monax materiam possit materiari?

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

    Thanks again everyone! I'm sure I'll have another one soon.

+ 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