+ Reply to Thread
Results 1 to 13 of 13

Isolating information within a cell

  1. #1
    Registered User
    Join Date
    06-22-2010
    Location
    PA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Isolating information within a cell

    Hey, i've got a series of numbers that are not all in the same format:

    01-1001 A
    01-1002 A
    01-1003 B
    011004-A
    011005-B
    01-1006 C


    I want it to look like:

    011001.....A
    011002.....A
    011003.....B
    011004.....A
    011005.....B
    011006.....C


    I've gotten this far using 'Text to Columns" and separating it by the " " [space]. I can't seem to get the "-" to do what i want though because they appear in both formats:

    01-1001.....A
    01-1002.....A
    01-1003.....B
    011004-A
    011005-B
    01-1006.....C

    Is there a way to select the cell that contain only "##-###" and not the "######-"?? There are over 5000 data entries so would really prefer the computer to do this for me..
    Last edited by NBVC; 07-19-2010 at 02:12 PM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Isolating information within a cell

    Perhaps?

    Assuming first entry is in A1,

    In B1:

    =REPLACE(SUBSTITUTE(SUBSTITUTE(A1,"-",""),C1,""),3,0," ")

    in C1:

    =RIGHT(A1)

    both copied down.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Isolating information within a cell

    1) Put data in column A.

    2) In B1 put this formula and copy down:
    =LEFT(SUBSTITUTE(SUBSTITUTE(A1," ",""),"-",""),6)

    3) In C1 put this formula and copy down:
    =RIGHT(A1,1)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Isolating information within a cell

    Or using a macro:

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

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

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Isolating information within a cell

    Hello cDuck28Z,

    Here is another VBA macro. This assumes the data is in column "A" of the ActiveSheet. It will replace the values that match your criteria.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Registered User
    Join Date
    06-22-2010
    Location
    PA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Isolating information within a cell

    Quote Originally Posted by JBeaucaire View Post
    1) Put data in column A.

    2) In B1 put this formula and copy down:
    =LEFT(SUBSTITUTE(SUBSTITUTE(A1," ",""),"-",""),6)

    3) In C1 put this formula and copy down:
    =RIGHT(A1,1)
    Sorry, i should have provided better example data. There are not only letters but also numbers; ex:

    01-0100 01
    01-0102 01
    010103-02
    01-1001 A
    01-1002 A
    01-1003 B
    011004-A
    011005-B
    01-1006 C
    01-1007 02
    011008-01



    Everything is good, but if my number is: 99-0199 01, my output becomes 99 99.....01. It seems to delete the "01" AFTER the "-" if the last two numbers are also 01

    I've included a copy of the file i am working on. See cell B1 for an example i created or cell B43:B44 for the original problem example (both are the same, i just created an example at the top to make things easier)
    Attached Files Attached Files

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Isolating information within a cell

    It looks like you are using the formulas I provided... if so, change the formula in B1 to:

    =REPLACE(SUBSTITUTE(SUBSTITUTE(A1,"-",""),C1,"",(LEN(A1)-LEN(SUBSTITUTE(A1,C1,"")))/LEN(C1)),3,0," ")

    copied down...

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Isolating information within a cell

    Hello cDuck28Z,

    The VBA solution I posted will deal with alpha-numeric strings at the end. If you are looking for a formula based answer then you should post your question to the Excel General forum.

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Isolating information within a cell

    I also forgot to mention to change the formula in C1 to:


    =TRIM(RIGHT(A1,2)) to get rid of space and work with new formula in B1....

  10. #10
    Registered User
    Join Date
    06-22-2010
    Location
    PA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Isolating information within a cell

    Quote Originally Posted by NBVC View Post
    It looks like you are using the formulas I provided... if so, change the formula in B1 to:

    =REPLACE(SUBSTITUTE(SUBSTITUTE(A1,"-",""),C1,"",(LEN(A1)-LEN(SUBSTITUTE(A1,C1,"")))/LEN(C1)),3,0," ")

    copied down...
    Quote Originally Posted by cDuck28Z
    Works Perfectly!! Thank you!!!
    Works ALMOST perfectly!! Found one error. Check out cell C 102 with the new formula. It keeps the "-" in column C, and doesn't remove the "B" after the numbers and dash..?


    ..New file uploaded with new formulas from posts
    Attached Files Attached Files
    Last edited by cDuck28Z; 07-19-2010 at 01:08 PM.

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Isolating information within a cell

    In C1:

    =TRIM(SUBSTITUTE(RIGHT(A1,2),"-",""))

    copied down.

  12. #12
    Registered User
    Join Date
    06-22-2010
    Location
    PA
    MS-Off Ver
    Excel 2003
    Posts
    13

    Re: Isolating information within a cell

    Quote Originally Posted by NBVC View Post
    In C1:

    =TRIM(SUBSTITUTE(RIGHT(A1,2),"-",""))

    copied down.
    Got it!!! =D
    Last edited by cDuck28Z; 07-20-2010 at 08:05 AM.

  13. #13
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Isolating information within a cell

    Can you give me an example?

+ 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