+ Reply to Thread
Results 1 to 7 of 7

Excel VBA UDF to find and substitute substring, with wildcards, from text string. Help

  1. #1
    Registered User
    Join Date
    05-22-2022
    Location
    costa rica
    MS-Off Ver
    365
    Posts
    3

    Excel VBA UDF to find and substitute substring, with wildcards, from text string. Help

    Looking everywhere, I haven't been able to find an Excel VBA user defined function to find and replace a substring, with wildcards, from text string.

    Something like, Example 1:

    A1: "THIS IS THE ORIGINAL STRING"

    Function in A2: NewSubstitute(A1,"O*L","NEW")

    Result in A2: "THIS IS THE NEW STRING"

    Example 2:

    A1: "THIS IS THE ORIGIN, ORIGINAL, ORIGINALE, STRING"

    Function in A2: NewSubstitute(A1,"O*,","NEW")

    Result in A2: "THIS IS THE NEW NEW NEW STRING"


    Help MUCH appreciated! Thanks!!!!!!

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

    Re: Excel VBA UDF to find and substitute substring, with wildcards, from text string. Hel

    Quote Originally Posted by infottico View Post
    A1: "THIS IS THE ORIGINAL STRING"

    Function in A2: NewSubstitute(A1,"O*L","NEW")

    Result in A2: "THIS IS THE NEW STRING"

    A1: "THIS IS THE ORIGIN, ORIGINAL, ORIGINALE, STRING"

    Function in A2: NewSubstitute(A1,"O*,","NEW")

    Result in A2: "THIS IS THE NEW NEW NEW STRING"
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-22-2022
    Location
    costa rica
    MS-Off Ver
    365
    Posts
    3

    Re: Excel VBA UDF to find and substitute substring, with wildcards, from text string. Hel

    Wow, works perfectly!!!!!!! Thanks for the Quick reply!!!!!

  4. #4
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,381

    Re: Excel VBA UDF to find and substitute substring, with wildcards, from text string. Hel

    Another variant with Regex

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-22-2022
    Location
    costa rica
    MS-Off Ver
    365
    Posts
    3

    Re: Excel VBA UDF to find and substitute substring, with wildcards, from text string. Hel

    This variant (JEC) did not work, as New Subtitle, supplied by jindon, did.

    A3: "A02AB05, A12AA12, A16AX05, B01AA08, B05XA08, B05XA17, L03AX13, V03AE04"

    A2: NewSubstitute(A3,"A1*,","") -> "A02AB05, B01AA08, B05XA08, B05XA17, L03AX13, V03AE04" (as required)

    A2: JEC(A3,"A1*,","") -> "A02AB05, A12AA12, A16AX05, B01AA08, B05XA08, B05XA17, L03AX13, V03AE04" (did not work)

  6. #6
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,381

    Re: Excel VBA UDF to find and substitute substring, with wildcards, from text string. Hel

    You don't need the * in my UDF. Forgot to tell you, my bad
    Now I see more examples, it will fail in other cases too.

    =JEC(A3,"A1,","")

  7. #7
    Forum Expert
    Join Date
    10-11-2021
    Location
    Netherlands
    MS-Off Ver
    365
    Posts
    1,381

    Re: Excel VBA UDF to find and substitute substring, with wildcards, from text string. Hel

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

+ 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. Find the index of substring in whole string in one cell
    By jaryszek in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 10-21-2021, 06:16 AM
  2. [SOLVED] Find the index of substring in whole string in one cell
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-21-2021, 06:01 AM
  3. [SOLVED] Find indexnumber of substring in string
    By MaartenRo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-19-2021, 06:11 AM
  4. [SOLVED] ForLoop to Find string value as part of substring in another cell
    By skydivetom in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-08-2021, 05:19 PM
  5. [SOLVED] Find substring within a string, from a list
    By NotSwank in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-06-2014, 10:27 AM
  6. [SOLVED] Need help completing a formula to find and substitute a character in a text string...
    By danielneedssomehelp in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-27-2014, 11:32 AM
  7. [SOLVED] Find the position of a substring in a string
    By nemo66ro in forum Excel General
    Replies: 6
    Last Post: 10-22-2012, 01:21 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