+ Reply to Thread
Results 1 to 21 of 21

Remove words by substring list

  1. #1
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Question Remove words by substring list

    How to remove or replace familiar words in string, by list of familiar stubs of that words?
    List contain ~30 stubs (substrings). With all of this I expect substitute hundreds matching words.

    dOAb3.png

    Attention! Some words contain two different stubs, and this can create conflict in substitution.
    I suggest to use case insensitive functions to exclude double length of formula.
    I think is better to replace/substitue, instead of delete/trim because in that way we can meke correction in word, not just trimming.

    I post in Formula thread because I prefer only excel formula, without vba or power query and without helper columns.
    But any suggestion is helpful for different types of users, not only for me.

    Here is the workbook:
    Attached Files Attached Files
    Last edited by Losai; 03-14-2022 at 04:51 AM. Reason: Accuracy

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

    Re: Remove matching words in excel

    Hi there.

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 non-editable pictures.

    Please read the yellow banner about sample worksheets, at the top of the screen. Act on its guidelines and post a SMALL sample sheet complete with an explanation and some expected results.
    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

  3. #3
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove matching words in excel

    Ok, I agree. But in workbook is no calculation, because i dont know how to build this kind of formula.

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

    Re: Remove words by substring list

    In your version of Excel... do you have the TEXTJOIN function? Are using a PC or a Mac?

  5. #5
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    I use Excel 2019 on PC, with TEXTJOIN function included.

  6. #6
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,477

    Re: Remove words by substring list

    Its better with VBA code. Unforturnatly, it is not accepted!
    Quang PT

  7. #7
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Quote Originally Posted by bebo021999 View Post
    Its better with VBA code. Unforturnatly, it is not accepted!
    If you have real solution, please send me a private message.

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

    Re: Remove words by substring list

    It can be done by formula but is made difficult 1) by so many stubs and 2) different capitalisation within stubs. VBA is probably better.

    =IFERROR(TEXTJOIN(" ",,FILTERXML("<A><B>"&SUBSTITUTE(A2," ","</B><B>")&"</B></A>","//B[not(contains(., 'auti') or contains(., 'AUTI') or contains(., 'tion') or contains(., 'mpl') or contains(., 'Mpl'))]")),"")
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Quote Originally Posted by Glenn Kennedy View Post
    It can be done by formula but is made difficult 1) by so many stubs and 2) different capitalisation within stubs. VBA is probably better.

    =IFERROR(TEXTJOIN(" ",,FILTERXML("<A><B>"&SUBSTITUTE(A2," ","</B><B>")&"</B></A>","//B[not(contains(., 'auti') or contains(., 'AUTI') or contains(., 'tion') or contains(., 'mpl') or contains(., 'Mpl'))]")),"")

    Its working very cool, but how many stubs will accept this function?

    For VBA solution... I must to make new post in VBA section?

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

    Re: Remove words by substring list

    Close this thread... and post in the VBA sub-forum, where it will show up as having no replies.

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

  11. #11
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Thank You Glenn, I will do this.
    Also I solve the problem with capitalization problem in FILTERXML

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

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

    Re: Remove words by substring list

    I had thought that the TRANSLATE needed to be repeated endlessly.... if not, then you MIGHT manage with the formula... I think XPath allows for 4096 bytes.

  13. #13
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Honestly, I dont know how to use Xpath, if is possible show me please

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

    Re: Remove words by substring list

    I think it DOES need to be repeated. See row 14... It does not exclude Mpl

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

    Re: Remove words by substring list

    Is it necessary to include the case? Could you just not use LOWER($A2) instead of $A2?

  16. #16
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Quote Originally Posted by Glenn Kennedy View Post
    I think it DOES need to be repeated. See row 14... It does not exclude Mpl
    I misseed this. You right. Thank you

  17. #17
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Quote Originally Posted by Glenn Kennedy View Post
    Is it necessary to include the case? Could you just not use LOWER($A2) instead of $A2?
    I try LOWER and its enough for me, very nice. But I still have curiosity how to do this without touch capitalization in string.

  18. #18
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,253

    Re: Remove words by substring list

    You can shorten somewhat by only translating the characters in each criterion - for example:

    Please Login or Register  to view this content.
    rather than:

    Please Login or Register  to view this content.
    Unfortunately XPath 1 doesn't allow things like matches()
    Remember what the dormouse said
    Feed your head

  19. #19
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Quote Originally Posted by rorya View Post
    You can shorten somewhat by only translating the characters in each criterion - for example:

    Please Login or Register  to view this content.
    rather than:

    Please Login or Register  to view this content.
    Unfortunately XPath 1 doesn't allow things like matches()


    Translation for each stub worked very good, but excel have there length limitation.
    I think Xpath can help, but I dont know how

  20. #20
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,213

    Re: Remove words by substring list

    @rorya great point.

    Xpath length at 1024 character

    if you need to remove 30+ substrings then use nested FilterXML
    where F2:F39 are lower case substrings


    Please Login or Register  to view this content.
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    03-12-2022
    Location
    Bucharest
    MS-Off Ver
    2019
    Posts
    35

    Re: Remove words by substring list

    Quote Originally Posted by Bo_Ry View Post
    @rorya great point.

    Xpath length at 1024 character

    if you need to remove 30+ substrings then use nested FilterXML
    where F2:F39 are lower case substrings
    Helper column its a good alternative. Thank you.

+ 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] How to Remove Certain words automatically from Excel
    By drp99246 in forum Excel General
    Replies: 1
    Last Post: 03-16-2019, 01:34 AM
  2. [SOLVED] Find matching words in a text string and return one of four words
    By alecoute in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-12-2018, 12:33 PM
  3. Replies: 6
    Last Post: 10-19-2018, 02:44 PM
  4. remove words and get result in other cell in excel
    By notbanme in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-23-2016, 05:31 AM
  5. [SOLVED] Macro to remove 650 stop words from excel text
    By PiaHarrison in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-18-2016, 03:56 PM
  6. [SOLVED] Remove duplicate rows by matching values across columns in Excel 2007
    By guest2013 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-15-2013, 12:00 AM
  7. [SOLVED] Find matching words in 10 columns and add row numbers of matching words
    By zeke 29 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 08-03-2012, 09:57 AM

Tags for this Thread

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