+ Reply to Thread
Results 1 to 12 of 12

Seperate a info in a cell with formula or script

  1. #1
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Seperate a info in a cell with formula or script

    Hi Everyone,

    I've been looking at this for quite a time but i don't see any easy way to solve it.

    I also added a testbook.
    Basicly what i want is in cell C7, the same information as in B7, but without letters, if it contains any.

    Can someone help me fix this?


    Thanks!!
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Seperate a info in a cell with formula or script

    Hello Crispy try this in C7
    =LEFT(B7,4)&"-"&MID(B7,FIND("-",B7)+1,4)


    this will work till you data setup is as in your sample file. If it can change please let me know
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    WANT TO SAY THANKS, HIT ADD REPUTATION (*) AT THE BOTTOM LEFT CORNER OF THE POST

    More we learn about excel, more it shows us, how less we know about it.

    for chemistry
    https://www.youtube.com/c/chemistrybyshivaansh

  3. #3
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: Seperate a info in a cell with formula or script

    Hi Hemesh,

    Thanks! Didn't really now about the FIND function.
    It does solve my problem in the example, however, the format of the information givin in B7 isn't always fixed.

    It can differ from 1-2, 23-1333, 1444a-11150B, 15950B-1434B. Do you know what i mean?
    Do you have any solution for that?

    Regards

  4. #4
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: Seperate a info in a cell with formula or script

    Hi,

    I think my first example file wasn't complete enough and i updated it.
    As you can see, it not only contains letters but also versions like "-2" after a "link".

    All of this should be removed. So for example 9095B-11071Z-2 should become 9095-11071

    I added a new xlsx file.

    Thanks in advance!!!
    Attached Files Attached Files

  5. #5
    Valued Forum Contributor john55's Avatar
    Join Date
    10-23-2010
    Location
    Europe
    MS-Off Ver
    Excel for Microsoft 365
    Posts
    2,028

    Re: Seperate a info in a cell with formula or script

    hi,
    I used it in the past, see if it helps you
    Please Login or Register  to view this content.
    Regards, John55
    If you have issues with Code I've provided, I appreciate your feedback.
    In the event Code provided resolves your issue, please mark your Thread as SOLVED.
    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

    ...enjoy -funny parrots-

  6. #6
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Seperate a info in a cell with formula or script

    Hello Crispy copy and paste this in B7 .
    =IF(ISNUMBER(LEFT(B7,FIND("-",B7)-1)+0),LEFT(B7,FIND("-",B7)-1),LEFT(B7,FIND("-",B7)-2))&"-"&IF(ISNUMBER(FIND("-",B7,FIND("-",B7)+1)),IF(AND(CODE(RIGHT(TRIM(MID(B7,FIND("-",B7)+1,FIND("-",B7,FIND("-",B7)+1)-FIND("-",B7)-1)),1))>=65,CODE(RIGHT(TRIM(MID(B7,FIND("-",B7)+1,FIND("-",B7,FIND("-",B7)+1)-FIND("-",B7)-1)),1))<=122),MID(TRIM(MID(B7,FIND("-",B7)+1,FIND("-",B7,FIND("-",B7)+1)-FIND("-",B7)-1)),1,LEN(TRIM(MID(B7,FIND("-",B7)+1,FIND("-",B7,FIND("-",B7)+1)-FIND("-",B7)-1)))-1),MID(TRIM(MID(B7,FIND("-",B7)+1,FIND("-",B7,FIND("-",B7)+1)-FIND("-",B7)-1)),1,LEN(TRIM(MID(B7,FIND("-",B7)+1,FIND("-",B7,FIND("-",B7)+1)-FIND("-",B7)-1))))),IF(AND(CODE(RIGHT(B7,1))>=65,AND(CODE(RIGHT(B7,1))<=122)),MID(TRIM(MID(B7,FIND("-",B7)+1,30)),1,LEN(TRIM(MID(B7,FIND("-",B7)+1,30)))-1),TRIM(MID(B7,FIND("-",B7)+1,30))))

  7. #7
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Seperate a info in a cell with formula or script

    Find attached file

    if you are satisfied with the ans click " * " add rep icon in the bottom left corner of my post
    To Mark Thread as solved go to thread tools and mark as solved
    Attached Files Attached Files

  8. #8
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: Seperate a info in a cell with formula or script

    Hi Hemesh,

    ****** that's what i call a formula.... Damn, thanks! and it does work! Now i can spend an hour trying to figure this formula out to check what it does exactly, lol! Thanks again!


    Hi John55,

    Thanks for your macro. It almost works. When you start it you can see for example in cell C12, it makes 9095-11071-2, while it should be 9095-11071.

  9. #9
    Forum Expert
    Join Date
    02-19-2013
    Location
    India
    MS-Off Ver
    07/16
    Posts
    2,386

    Re: Seperate a info in a cell with formula or script

    Thanks for the rep crispy ! Please mark thread as solved go to thread tools mark as solved

  10. #10
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Seperate a info in a cell with formula or script

    this somewhat shorter array formula in c7 should do it
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by martindwilson; 10-01-2013 at 05:33 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  11. #11
    Forum Contributor
    Join Date
    06-14-2013
    Location
    jk
    MS-Off Ver
    Excel 2007
    Posts
    326

    Re: Seperate a info in a cell with formula or script

    Hi martindwilson,

    It results in #N/A.

    Do i miss something?

  12. #12
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Seperate a info in a cell with formula or script

    ARRAY entered with ctrl+shift+enter see link in my signature

+ 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. Looking up info from a seperate Excel file to fill multiple cell values
    By JesseM in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-29-2010, 05:28 PM
  2. Replies: 3
    Last Post: 04-15-2010, 08:36 PM
  3. Taking seperate pieces of info from one cell into two others
    By Don Juan in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-22-2008, 07:35 PM
  4. Replies: 2
    Last Post: 11-15-2005, 12:10 PM
  5. Replies: 0
    Last Post: 11-14-2005, 09:25 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