+ Reply to Thread
Results 1 to 4 of 4

grab number from string based on some rules

  1. #1
    Registered User
    Join Date
    04-17-2020
    Location
    Newcastle
    MS-Off Ver
    office 365
    Posts
    66

    grab number from string based on some rules

    Hi Team

    I have a column with thousands of string values like the one below. I need to get the number after the second semicolon.

    So that would be 55033 in the example below, this number could be 5,6 or 7 characters, basically though i need the number between the second semicolon and the underscore.

    AT_29&BI=22234&NP=123689582_0;60736_0!0;55033_609264142928019.000!0&DG=60766;0;1.000&NM=0&sfnew=&SS=5&RM=0

    thanks
    Gary

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,820

    Re: grab number from string based on some rules

    Try this:

    =TRIM(LEFT(SUBSTITUTE(MID(SUBSTITUTE(A1,";","|",2),FIND("|",SUBSTITUTE(A1,";","|",2))+1,10),"_",REPT(" ",99)),99))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: grab number from string based on some rules

    Here is another formula that should also work (same number of function calls as Ali's formula)...

    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND("_",A1,FIND(";",A1,FIND(";",A1)+1))-1),";",REPT(" ",99)),99))

    And here is yet another way which uses one less function call...

    =MID(REPLACE(A1,FIND("_",A1,FIND(";",A1,FIND(";",A1)+1)),999,""),FIND(";",A1,FIND(";",A1)+1)+1,9)
    Last edited by Rick Rothstein; 09-16-2020 at 10:47 AM.

  4. #4
    Registered User
    Join Date
    04-17-2020
    Location
    Newcastle
    MS-Off Ver
    office 365
    Posts
    66

    Re: grab number from string based on some rules

    Thanks Both - those options worked a treat

+ 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: 2
    Last Post: 01-05-2018, 12:31 AM
  2. [SOLVED] How to split/grab number from string?
    By QuantEdge in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 08-18-2017, 04:57 PM
  3. [SOLVED] Reference Another Workbook to Grab UPC Based on Part Number
    By Casthenative in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-08-2016, 04:41 PM
  4. Generating random number string based on Alphanumeric String
    By ridemeve in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-15-2014, 04:56 PM
  5. Validate a number in the cell based on rules
    By aravindvin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-17-2013, 10:54 AM
  6. Replies: 0
    Last Post: 04-22-2012, 06:08 PM
  7. How do I grab the date from a text string?
    By [email protected] in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-06-2006, 03:00 AM

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