+ Reply to Thread
Results 1 to 11 of 11

Extract 5th string onwards but exclude 6th string onwards if found a specificlist of words

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

    Extract 5th string onwards but exclude 6th string onwards if found a specificlist of words

    Hi

    Would like to extract the 5th string onwards but need to exclude the 6th string onwards only if the 6th word has DMZ, DB, WEB, APP, HOT, COLD. For example

    C2_F6_AM_SHS_GROUPGST_DB Result: GROUPGST
    C2_F6_AM_SHS_ECLAIM Result: ECLAIM
    C2_F6_AM_SHS_EQUIBASE Result: EQUIBASE
    C2_F6_AM_SHS_TREX_APP Result: TREX
    C2_F6_AM_CAD_STARS_DMZ Result: STARS
    C3_F2_AD_SHS_ORMS_HOT Result: ORMS
    C3_F4_AD_SHS_ORMS_COLD Result: ORMS
    C3_F4_AD_SHS_FINSS_AMLA_ETL Result: FINSS_AMLA_ETL
    C1_F2_AD_WBP_TIPLUS_HOT_B4EOD Result: TIPLUS
    C0_F2_AU_CB_AMBGAIX85_DB_FS Result: AMBGAIX85

    I used this formula =MID(J46,SEARCH("_",J46,SEARCH("_",J46))+11,256), but unable to trim the 6th string if found the list of words in the same formula.

    Can anyone please advise. Thank you.

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

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    =TRIM(MID(SUBSTITUTE(A1,"_",REPT(" ",LEN(A1))),(5-1)*LEN(A1)+1,LEN(A1)))

    change A1 with your actual cell reference
    Attached Files Attached Files

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    If your data is in A1 onwards, put the below formula in B1

    Please Login or Register  to view this content.
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.

    See the attached file..
    Attached Files Attached Files
    Last edited by NeedForExcel; 01-14-2016 at 05:04 AM.
    Cheers!
    Deep Dave

  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 5th string onwards but exclude 6th string onwards if found a specificlist of w

    Maybe this

    Formula: copy to clipboard
    Please Login or Register  to view this content.




    A
    B
    1
    Text string Output
    2
    C2_F6_AM_SHS_GROUPGST_DB Result: GROUPGST GROUPGST
    3
    C2_F6_AM_SHS_ECLAIM Result: ECLAIM ECLAIM
    4
    C2_F6_AM_SHS_EQUIBASE Result: EQUIBASE EQUIBASE
    5
    C2_F6_AM_SHS_TREX_APP Result: TREX TREX
    6
    C2_F6_AM_CAD_STARS_DMZ Result: STARS STARS
    7
    C3_F2_AD_SHS_ORMS_HOT Result: ORMS ORMS
    8
    C3_F4_AD_SHS_ORMS_COLD Result: ORMS ORMS
    9
    C3_F4_AD_SHS_FINSS_AMLA_ETL Result: FINSS_AMLA_ETL FINSS
    10
    C1_F2_AD_WBP_TIPLUS_HOT_B4EOD Result: TIPLUS TIPLUS
    11
    C0_F2_AU_CB_AMBGAIX85_DB_FS Result: AMBGAIX85 AMBGAIX85
    Sheet: Sheet1
    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
    Forum Contributor
    Join Date
    05-22-2015
    Location
    Malaysia
    MS-Off Ver
    MS365
    Posts
    197

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    Hi,
    The formula from NeedForExcel works because it did not exclude from C3_F4_AD_SHS_FINSS_AMLA_ETL if found DMZ, DB, WEB, APP, HOT, COLD at the 6th string.

    But this formula did not work. if found WEB in the 5th string without an underscore, it should not exclude. _DMZ, _DB, _WEB, _APP, _HOT, _COLD will always comes after an underscore. Example:

    C2_F3_AM_GIN_AMGWEB : This Formula did not work. Result should be AMGWEB because no underscore.

    C2_F3_AM_REB_ISENTRIC_WEB : Formula worked as the result shows ISENTRIC. Reason is it has an underscore _WEB
    C3_F4_AD_SHS_ORMS_COLD_B4EOD : Formula worked as the result shows ORMS. Reason is _COLD onwards has to be trimmed.

  6. #6
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    So do you want me to have _DMZ, _DB, _WEB, _APP, _HOT, _COLD in the formula instead of DMZ, DB, WEB, APP, HOT, COLD?

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

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    Not really. I'm just informing that all these words will comes with an underscore before or after.

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

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    @ suchetherrah
    Assuming your data is in A1 then copy paste below in B1

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    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

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

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    Thank you all for the contribution. Formula form Hemesh worked.

    The formula is really complex which I need time to understand.

  10. #10
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    Please Login or Register  to view this content.
    try this formula
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

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

    Re: Extract 5th string onwards but exclude 6th string onwards if found a specificlist of w

    Hi nflsales,
    Sorry for the late reply. The formula worked but it did not retain the 6th string if it's not part of the list of {"dmz","db","web","app","hot","cold"}.

    Example
    C3_F4_AD_SHS_ORMS_B4EOD_COLD, result should be ORMS_B4EOD but displays ORMS_B4EOD_COLD
    C3_F4_AD_SHS_ORMS_COLD_B4EOD, formula worked where it shows ORMS

    Meaning after the 6th string, if these {"dmz","db","web","app","hot","cold"} are not exist, then it should retain otherwise remove from that word onwards.

+ 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. [SOLVED] Hide Columns IF Row 2 onwards is Blank
    By Wheelie686 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-01-2015, 04:45 PM
  2. [SOLVED] Extract all the words from a string for processing, while leaving string intact.
    By staggers47 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-10-2014, 02:02 PM
  3. [SOLVED] Hide columns if empty from Row 3 onwards vba
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2014, 03:41 AM
  4. [SOLVED] VBA code to select today() onwards from filter
    By cmb80 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-18-2014, 06:39 AM
  5. Sum values from a certain date onwards
    By manny_cb in forum Excel General
    Replies: 3
    Last Post: 08-13-2010, 02:19 AM
  6. Sorting from row A6 onwards
    By teebird in forum Excel General
    Replies: 2
    Last Post: 05-18-2007, 02:46 AM
  7. Replies: 0
    Last Post: 08-12-2005, 09:05 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