+ Reply to Thread
Results 1 to 3 of 3

Replace a substring using wildcard in variable

  1. #1
    Registered User
    Join Date
    11-01-2019
    Location
    Sydney, Australia
    MS-Off Ver
    Professional Plus 2019
    Posts
    1

    Question Replace a substring using wildcard in variable

    I need to replace a substring in a string in a variable.

    For example, in a string that contains "&Cost=6789&" i want to replace the "6789" with a new numeric value, without knowing in advance the value (6789) that I am replacing, and without knowing in advance how long the (6789) string is.

    Using wildcards, I would be replacing "&Cost=*&" with "&Cost=" & NewValue where NewValue is the value I want to replace 6789 with.

    I think I found a solution eralier that didn't require me to use excel cells, but with moving between work and home computers I've misplaced it. From memory it used something like Application.WorksheetFunction.replace , but I don't recall the exact code.

  2. #2
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,004

    Re: Replace a substring using wildcard in variable

    without knowing in advance how long the (6789) string is.
    but do you know the possible minimum and maximum length of the number? say 4 to 10?
    and could there be multiple match in the string? something like "This is &Cost=6789& and &Cost=118910&"

  3. #3
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Replace a substring using wildcard in variable

    Hi
    May be
    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. Macro to search cells for substring and replace contents of cell if substring is found
    By robbyvegas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2015, 06:40 AM
  2. [SOLVED] Find: Using wildcard, but don't replace with wildcard
    By JimDandy in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-06-2013, 05:39 PM
  3. Extract variable length substring from a string
    By charron9 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-24-2013, 11:52 AM
  4. Find and Replace Substring
    By ncalenti in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-14-2012, 06:54 PM
  5. [SOLVED] Extract Substring, then Ignore that Substring, while collecting data from Other substrings
    By Sameki121 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-17-2012, 05:21 PM
  6. Find and Replace the character in a substring.
    By saikumar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-14-2009, 04:44 AM
  7. How to replace cells with wildcard?
    By betty77 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-06-2006, 01:55 PM

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