+ Reply to Thread
Results 1 to 9 of 9

SUBSTITUTE Function

  1. #1
    Registered User
    Join Date
    08-20-2013
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2013
    Posts
    41

    SUBSTITUTE Function

    Hi,

    I have a cell with 3 characters in that can be either W, L, D or -. eg WLD, WWW, LLL WD- etc.

    I wish to replace the W with an L and the L with a W, but I cannot work out how to do it.

    I have tried SUBSTITUTE(E3,{"W";"L"},{"L";"W"}) which converts the W to L but not the other way around. Have I got the syntax correct or should I be using a different function.

    Many thanks

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

    Re: SUBSTITUTE Function

    Try it like this:

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(E3,"L","z"),"W","L"),"z","W")

    Note that L is changed temporarily to z.

    Hope this helps.

    Pete

  3. #3
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: SUBSTITUTE Function

    Hi,

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

  4. #4
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: SUBSTITUTE Function

    Ah! I knew there had to be a simpler way Pete!

  5. #5
    Forum Contributor
    Join Date
    07-02-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    197

    Re: SUBSTITUTE Function

    Or even simpler:

    Use Find and replace

    Find: W
    Replace with: Lx
    Find: L
    Replace with: W
    Find: Lx
    Replece with: L

  6. #6
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: SUBSTITUTE Function

    @Rambo: replacing W with Lx and then replacing L with W will result in every instance of Lx being replaced with Wx, which will not lead to the desired outcome

  7. #7
    Forum Contributor
    Join Date
    07-02-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    197

    Re: SUBSTITUTE Function

    Quote Originally Posted by ajryan88 View Post
    @Rambo: replacing W with Lx and then replacing L with W will result in every instance of Lx being replaced with Wx, which will not lead to the desired outcome
    Sorry, ajryan88 - you are right

    Then try:

    Use Find and replace

    Find: W
    Replace with: xx
    Find: L
    Replace with: W
    Find: xx
    Replace with: L

  8. #8
    Registered User
    Join Date
    08-20-2013
    Location
    Nottingham, England
    MS-Off Ver
    Excel 2013
    Posts
    41

    Re: SUBSTITUTE Function

    This is for an ongoing project with new data every day so although FIND and REPLACE would accomplish what I wanted the SUBSTITUTE example from Pete_UK was exactly what I wanted.

    Many thanks to all.

  9. #9
    Forum Contributor
    Join Date
    07-02-2013
    Location
    Stockholm, Sweden
    MS-Off Ver
    Excel 2003 and 2007
    Posts
    197

    Re: SUBSTITUTE Function

    Quote Originally Posted by Onceageordie View Post
    This is for an ongoing project with new data every day so although FIND and REPLACE would accomplish what I wanted the SUBSTITUTE example from Pete_UK was exactly what I wanted.

    Many thanks to all.
    But then you must use a helper column. Isn't better better to use use Find and replace on the existing data?

+ 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. Substitute for Range function
    By joey1984 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-11-2013, 01:54 AM
  2. Substitute function with VLOOKUP
    By gach in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-24-2013, 10:59 AM
  3. [SOLVED] Substitute function in Excel
    By bjnockle in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-07-2013, 08:26 PM
  4. substitute function
    By mrggutz in forum Excel General
    Replies: 2
    Last Post: 02-18-2011, 08:54 AM
  5. Substitute worksheet function
    By SIGE in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2005, 05:06 AM

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