+ Reply to Thread
Results 1 to 14 of 14

Extract a word starts with a list of characters from a string

  1. #1
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Extract a word starts with a list of characters from a string

    Hi

    Would like to seek your assistance to extract a word from the raw data starts with "AMS, AMBG, MYDR, IB2K, MYPR...." and could be more.

    Raw data Result
    Primary:AMBG2Kabc:NT AMBG2Kabc
    MYDRVLXRAUTHNab:KUL MYDRVLXRAUTHNab
    IBTRBSQL:IB2KAAB:MSS IB2KAAB
    IB2KBB:UA IB2KBB
    RZ:MTP-MTP-ambgsun99:RDB ambgsun99
    AMBG2K999:AMBG2K999:MSS AMBG2K999
    AMS:KUL AMS


    Thank you.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Extract a word starts with a list of characters from a string

    Please post a sample showing expected outcomes.

  3. #3
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract a word starts with a list of characters from a string

    Hi,
    My apology, when I paste it, did not display correctly.

    Primary:AMBG2Kabc:NT
    Extract should be AMBG2Kabc

    MYDRVLXRAUTHNab:KUL
    Extract should be MYDRVLXRAUTHNab

    IBTRBSQL:IB2KAAB:MSS
    Extract should be IB2KAAB

    IB2KBB:UA
    Extract should be IB2KBB

    RZ:MTP-MTP-ambgsun99:RDB
    Extract should be ambgsun99

    AMBG2K999:AMBG2K999:MSS
    Extract should be AMBG2K999

    AMS:KUL
    Extract should be AMS

    ip.pipe:#99.9.999.99[2026]<NM>AMBG2K999DR</NM>
    Extract should be 99.9.999.99

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Extract a word starts with a list of characters from a string

    File required as people do not wish to type in your data.

    ip.pipe:#99.9.999.99[2026]<NM>AMBG2K999DR</NM>
    Extract should be 99.9.999.99
    Is this correct? Not AMBG2K999DR

  5. #5
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract a word starts with a list of characters from a string

    Hi,
    Yes, it's 2 different formulas.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Extract a word starts with a list of characters from a string

    Still no file or explanation why last example is required result.

    2 different formulas ... what are they?

  7. #7
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract a word starts with a list of characters from a string

    Hi,

    The 1st formula is would like to extract the hostname based on the list first few characters based on the list of AMS, AMBG, MYDR, IB2K, MYPR...." and could be more.
    It could be any where in the string.

    The 2nd formula, would like to extract the ip address only after the # before the [.

    Attached is the sample data. Please assist as we need to extract this everyday and massage the data using text to columns which is time consuming.

    Thank you.
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Extract a word starts with a list of characters from a string

    Looking at your file you are going to need a VBA-based solution. In order to do this, we need a list of all possible strings such as "AMS, AMBG .." etc.

    Doing extracts like these are not easy and are usually not 100% effective.

    For Ip you could use

    =MID(C3,FIND("#",C3)+1,FIND("[",C3)-FIND("#",C3)-1)

  9. #9
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract a word starts with a list of characters from a string

    Hi,

    Thank you for the response.
    The strings need to extract are AMS, AMAB, MYPV, MYDR, MYDV, EMAIL, AMS, AMBG, IB2K, MYPP, AMF, EXT, MCP, RENT, sa10

  10. #10
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Extract a word starts with a list of characters from a string

    Try the following:

    Please Login or Register  to view this content.
    Sheet2 has named ranges called "Codes".

    Ip is extracted using formula (in D3)
    Attached Files Attached Files

  11. #11
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,367

    Re: Extract a word starts with a list of characters from a string

    for first formula, put on B3 and copied down

    =TRIM(RIGHT(SUBSTITUTE(TRIM(TRIM(LEFT(RIGHT(" "&SUBSTITUTE(TRIM(A3),":",REPT(" ",60)),120),60))),"-",REPT(" ",255)),255))

  12. #12
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract a word starts with a list of characters from a string

    Hi Azumi,

    Let say, if I have this ip.pipe:#11.9.9.99[12345]<NM>AMBG2K123DR</NM>. I need to extract AMBG2K123DR only.

    All the data has <NM> at front of hostname and </NM>after the hostname.

    Need your assistance to have the formula to extract the hostname only. Thank you.

  13. #13
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,193

    Re: Extract a word starts with a list of characters from a string

    Try this: wonderful system will not allow me to post the code but it only a minor change to the previous.
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract a word starts with a list of characters from a string

    The formula is working beautifully. Thank you all for your assistance.

+ 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. Extract string between two characters
    By Alma in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-28-2016, 10:49 AM
  2. [SOLVED] extract string between two characters
    By JackSmith123 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-17-2015, 12:15 PM
  3. [SOLVED] Extract String from between 2 same characters
    By slamdunka in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-30-2014, 09:37 PM
  4. [SOLVED] Extract left characters from string with exception of 2 right characters
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-16-2012, 10:45 PM
  5. [SOLVED] Extract 1-2 characters from a string
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-14-2012, 07:53 PM
  6. EXTRACT all characters from a string
    By Blake 7 in forum Excel General
    Replies: 2
    Last Post: 03-11-2011, 07:06 AM
  7. Make a word bold if it starts with a particular character/string
    By lightsandsirens in forum Word Programming / VBA / Macros
    Replies: 9
    Last Post: 03-08-2010, 09:28 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