+ Reply to Thread
Results 1 to 4 of 4

Remove matching strings by multiple substrings

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

    Question Remove matching strings by multiple substrings

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

    stackoverflow5.png

    For this goal I use an array formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    But this formula have one big disadvantages: Length limitation (255 characters for values)

    So Glenn Kennedy suggest to code it in VBA.

    Attention! Some words contain two different stubs, and this can create conflict in substitution.
    Opinion! Is better to replace/substitute, instead of delete/trim because in that way we can make correction in word, not just trimming.
    Attached Files Attached Files
    Last edited by Losai; 03-14-2022 at 07:05 AM.

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Remove matching strings by multiple substrings

    will be more succint methods but

    Please Login or Register  to view this content.
    above, stored in Standard Module, would be called from cell along lines of:

    D2: =XTERMS(A2)

    if you wanted to change exclusion terms you can send these explicitly in optional 2nd param (pipe delimited), e.g.

    D2: =XTERMS(A2,"auti|mpl")
    would return different results

    note: UDF is case insensitive search by default (i.e. both AUTI and auti excluded) -- this can be modified if necessary by altering the InStr compare method
    Last edited by XLent; 03-14-2022 at 07:35 AM. Reason: missed lng declarations!

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,588

    Re: Remove matching strings by multiple substrings

    D2;
    =VBAReplace(A2,"auti","tion","mpl")

    Add/Remove substrings as you wish.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by jindon; 03-14-2022 at 07:59 AM.

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

    Re: Remove matching strings by multiple substrings

    Quote Originally Posted by jindon View Post
    D2;
    =VBAReplace(A2,"auti","tion","mpl")

    Add/Remove substrings as you wish.
    I like and i will use this.
    Im glad you highlite formula missing.
    Now is solved fully.
    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. Replace substrings in text strings
    By tkew in forum Excel General
    Replies: 2
    Last Post: 12-11-2020, 11:31 AM
  2. [SOLVED] Get strings between two strings in text file and remove the rest
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 24
    Last Post: 10-15-2018, 10:18 AM
  3. matching multiple text strings against a reference range
    By the_nibs in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-09-2015, 07:19 PM
  4. [SOLVED] Extract substrings from variable strings
    By WmBarth in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-13-2014, 06:10 AM
  5. Replies: 3
    Last Post: 03-04-2011, 02:25 PM
  6. Separating strings into substrings.
    By in forum Tips and Tutorials
    Replies: 1
    Last Post: 05-11-2005, 08:17 AM
  7. [SOLVED] Searching for Substrings Within Strings
    By Tiziano in forum Excel General
    Replies: 9
    Last Post: 01-06-2005, 12:06 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