+ Reply to Thread
Results 1 to 13 of 13

extract number from multiple occurrence delimiter of string excel

Hybrid View

  1. #1
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    MS Excel
    Posts
    6

    Exclamation extract number from multiple occurrence delimiter of string excel

    I'm trying to extract all the numbers from the left of the delimiter ":" . They can occur once or more.

    E.g. cell F2 contains BP2.2.1:40 BP2.2.1:50 BP2.2.1:60 BP2.2.1:70 BP2.4.1:80

    and what i want as a result is : BP2.2.1 BP2.2.1 BP2.2.1 BP2.2.1 BP2.4.1

    I've tried =IFERROR(LEFT(F2,FIND(":",F2)-2), " ") but only displays 1 out of a possible 4 in the cell.

    Any suggestions?

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: extract number from multiple occurrence delimiter of string excel

    Hi Manny339,
    Welcome to the Forum.

    Assuming your string is in A1, then try this......

    In B1
    =IFERROR(MID($A1,FIND("*",SUBSTITUTE(" "&$A1," ","*",COLUMNS($B1:B1))),FIND("^",SUBSTITUTE(" "&$A1,":","^",COLUMNS($B1:B1)))-FIND("*",SUBSTITUTE(" "&$A1," ","*",COLUMNS($B1:B1)))-1),"")
    and copy across (right) until you get blank cells.

    Is this what you are trying to achieve?
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    MS Excel
    Posts
    6

    Re: extract number from multiple occurrence delimiter of string excel

    Quote Originally Posted by sktneer View Post
    Hi Manny339,
    Welcome to the Forum.

    Assuming your string is in A1, then try this......

    In B1
    =IFERROR(MID($A1,FIND("*",SUBSTITUTE(" "&$A1," ","*",COLUMNS($B1:B1))),FIND("^",SUBSTITUTE(" "&$A1,":","^",COLUMNS($B1:B1)))-FIND("*",SUBSTITUTE(" "&$A1," ","*",COLUMNS($B1:B1)))-1),"")
    and copy across (right) until you get blank cells.

    Is this what you are trying to achieve?

    Hi, thanks for the reply.

    You solution only displays one result instead of the multiple strings in the cell with ":" as a delimiter.

    What I am trying to achieve is getiing everything from the left of the delimiter ":" with multiple occurances

    e.g. cell A1 = BP2.2.1:40 BP2.2.5:50
    result cell B1 =BP2.2.1 BP2.2.5

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: extract number from multiple occurrence delimiter of string excel

    Assuming your string is in F2: Try this formula in G2 and pull it to the right until you see blank cell

    Press Ctrl+F and type in :?? and click Replace. In Replace with press bar space once and Replace All

    =TRIM(MID(SUBSTITUTE(TRIM($F2)," ",REPT(" ",255)),(COLUMNS($A:A)-1)*255+1,255))


    ***Corrected formula
    Last edited by AlKey; 08-14-2014 at 10:03 AM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    MS Excel
    Posts
    6

    Re: extract number from multiple occurrence delimiter of string excel

    Quote Originally Posted by AlKey View Post
    Assuming your string is in F2: Try this formula in G2 and pull it to the right until you see blank cell

    Press Ctrl+F and type in :?? and click Replace. In Replace with press bar space once and Replace All

    =TRIM(MID(SUBSTITUTE(TRIM(SUBSTITUTE($F2,":"," "))," ",REPT(" ",255)),(COLUMNS($A:A)-1)*255+1,255))

    Sorry I'm a bit confused, i'm new to excel, the result should stay in the same cell.

    E.g. A1 = BP2.2.1:40 BP2.2.5:50 (all in one cell)
    result cell B1 =BP2.2.1 BP2.2.5 (all in one cell)

    and i want to repeat this for all the other cells.

    E.g. A2 = BP2.3.1:40 BP2.3.5:50 ( all in same cell)
    B2 = BP2.3.1 BP2.3.5 (all in same cell)

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: extract number from multiple occurrence delimiter of string excel

    One tweak to Alkey's formula, to return only the BP strings... again with the source data in f2...
    Formula: copy to clipboard
    TRIM(MID(SUBSTITUTE(TRIM(SUBSTITUTE($F2,":"," "))," ",REPT(" ",255)),(COLUMNS($A:A)*2-2)*255+1,255))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: extract number from multiple occurrence delimiter of string excel

    For that probably you will need a VBA solution to achieve this. Please find the attached workbook with two sheets Test1 and Test2. Both these sheets contain a Green Button, click this button to get the desired output. See if this is something you can work with.
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    MS Excel
    Posts
    6

    Re: extract number from multiple occurrence delimiter of string excel

    Quote Originally Posted by sktneer View Post
    For that probably you will need a VBA solution to achieve this. Please find the attached workbook with two sheets Test1 and Test2. Both these sheets contain a Green Button, click this button to get the desired output. See if this is something you can work with.
    Test sheet 1 is what i want to achieve, but is there any other way to do it without using VBA because I don't know how you got that green button there and where the code is beneath it

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: extract number from multiple occurrence delimiter of string excel

    @Today, 10:06 AM #5
    Manny339

    LOL, I think you effectively confused all of us If you if you simply need to get rid of :xx part of the string and keep everything in one cell you can use just this

    Press Ctrl+F and type in :?? and click Replace. In Replace with press bar space once and Replace All
    No need for formula.

  10. #10
    Registered User
    Join Date
    08-14-2014
    Location
    London
    MS-Off Ver
    MS Excel
    Posts
    6

    Re: extract number from multiple occurrence delimiter of string excel

    Quote Originally Posted by AlKey View Post
    @Today, 10:06 AM #5
    Manny339

    LOL, I think you effectively confused all of us If you if you simply need to get rid of :xx part of the string and keep everything in one cell you can use just this

    Press Ctrl+F and type in :?? and click Replace. In Replace with press bar space once and Replace All
    No need for formula.
    Not sure what you mean




    I did this this and nothing happened
    Last edited by Manny339; 08-14-2014 at 11:06 AM.

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: extract number from multiple occurrence delimiter of string excel

    See if you can go with Alkey's suggestion. That is pretty simple and straight forward.
    But if you want to continue with the VBA solution, there are two codes which are assigned to two green buttons on Test1 and Test2 sheets. To see the codes, follow these steps.
    Press Alt+F11 to open VBA editor --> On project pane on the left side of VBA editor --> You will find two modules "Module1" and "Module2" --> Double click on each module to see the code.
    The name of the code is pretty straight forward. The name itself will tell you what this code is doing.
    You can delete the green button from the sheets and whenever you want to execute the code, press Alt+F8 to open Macro window and select the correct macro from the macro list and click Run.

    Does that help?

  12. #12
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: extract number from multiple occurrence delimiter of string excel

    Ok, I will try this again.

    Copy and paste the entire column from the original location to a new column, select all rows in this column then follow steps bellow

    Press Ctrl+F and type in :?? and click Replace button. In Replace with press bar space once and Replace All.

  13. #13
    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 number from multiple occurrence delimiter of string excel

    Use Ctrl H instead of F
    Excel Guru in the making

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

+ 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. Replies: 12
    Last Post: 12-10-2014, 05:01 AM
  2. [SOLVED] How to Extract A Number from String if Text within the String Equals XYZ
    By tyrsfury in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-15-2012, 03:30 PM
  3. [SOLVED] Extract a mainly numeric string (ISSN number) from an arbitrary string
    By Buzzed Aldrin in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-04-2012, 01:49 PM
  4. Replies: 6
    Last Post: 03-27-2012, 06:00 AM
  5. Find the row number of the 2nd occurrence of a string in a range
    By seaottr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-03-2011, 06:52 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