+ Reply to Thread
Results 1 to 9 of 9

Without VBA replace all only the match string

  1. #1
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Without VBA replace all only the match string

    Hello,

    In the formula bar where the formula is ......\10 - October 2016\... ... ...\Oct 2016\....

    How do I do a replace where I can just change the above to ......\11 - November 2016\... ... ...\Nov 2016\....

    Where everything stays the same?

    I tried using \11 - November 2016\ * \Nov 2016\ and didn't work, anything that's in the middle is changed to the asterisk.

    Edit: For more clarification, assume that you have the following formula.

    Please Login or Register  to view this content.
    And you want to change it to

    Please Login or Register  to view this content.
    Because I want to keep everything all the same, EXCEPT the 10 - October 2016\... ... ...\[Name of the file Oct 2016.xlsx], so I highlight the range, and with Find and Replace, I put

    "\10 - October 2016\folder\[Name of the file Oct 2016.xlsx]" on Find What and
    "\11 - November 2016\folder\[Name of the file Nov 2016.xlsx]" on Replace With.

    Thus am wondering if there's a way in Excel, without using VBA, to be able to do using wild card like below and still able to retain. Example below.

    "\10 - October 2016\*Oct 2016.xlsx]" on Find What and
    "\11 - November 2016\*Nov 2016.xlsx]" on Replace With.
    Last edited by dluhut; 12-15-2016 at 01:03 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: Without VBA replace all only the match string

    I'd do it in two passes. 10 - October 2016 to 11 - November 2016 and then Oct 2016 to Nov 2016.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,732

    Re: Without VBA replace all only the match string

    Are those meant to be text values which look like dates, or actual date fields?

    It they are text values then you could use Find & replace twice, the first time to replace "October" with "November" and the second time to replace "Oct" with "Nov" (obviously, without the quotes).

    If they are actual dates, then you can enter the value 31 in a blank cell somewhere, select that cell and click < copy >, then move the cursor to select the cells with the dates in them, then right-click and choose Paste Special, then click against Add and against Values then OK then press the < Esc > key.

    Hope this helps.

    Pete

  4. #4
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Without VBA replace all only the match string

    Quote Originally Posted by TMS View Post
    I'd do it in two passes. 10 - October 2016 to 11 - November 2016 and then Oct 2016 to Nov 2016.
    Hi TMS,

    Thought of doing that too, but because what I'm trying to replace is an actual formula, and that it's actually has to do with external link to closed workbook, if I were to do it one by one, an annoying 'edit link' window that ask to reference to the correct workbook keeps coming up.

    That's why I'm doing the 'replace all' all at once.

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Without VBA replace all only the match string

    Try this

    in A2


    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"2016\10",B1),"October",C1),"Oct",D1)

    A1= "October" formula

    Please Login or Register  to view this content.
    B1="2016\11"

    C1="November"

    D1="Nov"

    all above without the quotes!

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Without VBA replace all only the match string

    Or more generic

    in B1:C2

    2016\10 October Oct
    2016\11 November Nov

    in A2

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1,$B$1,$B$2),$C$1,$C$2),$D$1,$D$2)

  7. #7
    Valued Forum Contributor
    Join Date
    04-13-2011
    Location
    Ottawa, Canada
    MS-Off Ver
    365
    Posts
    1,067

    Re: Without VBA replace all only the match string

    Hi John,

    I can't use a substitute or replace formula, because what I'm trying to replace itself is a formula.

    Think of it this way, those formula that I have is in cell A1 and it's going all the way down to say cell A10.

    What I'm trying to find and replace all is in cell range A1:A10 where they're an actual formula (that's why it started with an equal) and change any string that 'match' and still keep the others the same as is.

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,208

    Re: Without VBA replace all only the match string

    Then VBA is probably the only way.

  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,732

    Re: Without VBA replace all only the match string

    It makes more sense now that you have given better examples of what you have. You can do it in 4 passes of Find & Replace. Select all the cells with the formulae in (A1:A10 ?), then CTRL-H, and:

    Find What: =
    Replace With: $=
    Click Replace All

    Find What: October
    Replace With: November
    Click Replace All

    Find What: Oct
    Replace With: Nov
    Click Replace All

    Find What: $=
    Replace With: =
    Click Replace All

    Then you can close the dialogue box. The first changes the formula to a text string so that you can do the two passes on the month and the last one returns it to a formula.

    Hope this helps.

    Pete

+ 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. Wild Card?
    By mklindquist0815 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2016, 04:22 PM
  2. [SOLVED] Find and Replace using Wild Card characters
    By darren6060 in forum Excel General
    Replies: 3
    Last Post: 10-17-2013, 11:25 AM
  3. match formula with wild card in vba not working
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-18-2013, 09:55 AM
  4. [SOLVED] REPLACE with Array List with Wild Card
    By dluhut in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-29-2013, 11:01 AM
  5. [SOLVED] Excel Replace Function with wild card: Possible?
    By alfykunable in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-27-2011, 12:59 AM
  6. Replies: 2
    Last Post: 09-26-2011, 04:19 AM
  7. [SOLVED] Partial String Match & Wild Cards Using VLOOKUP
    By djDaemon in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-09-2006, 01:55 PM

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