+ Reply to Thread
Results 1 to 9 of 9

Replace Characters to Left of a String with Another String/Character

  1. #1
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Replace Characters to Left of a String with Another String/Character

    Hi

    I have 2 cells containing the following text:

    ZMT5 Eagle
    ZMT5GMT6 Eagle

    What I want to loop through each cell and write If statements such that if cell contains Eagle and number of characters in cell =10 (comfortable up until this point) then

    (part I'm not sure how to write) replace the 2 characters starting 3 to left of Eagle with a 1 else replace the 2 characters starting 3 to the left and 7 to the left of Eagle with a 1.

    So output from the loop would be as follows:

    ZM1 Eagle
    ZM1GM1 Eagle

    If anyone could tell me how to handle the string replacement piece, it would be greatly appreciated.
    Thanks

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Replace Characters to Left of a String with Another String/Character

    Will all the outputs be in the same format as showed ?

  3. #3
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Replace Characters to Left of a String with Another String/Character

    Hi Pepe

    When you say format, what do you mean in this context?

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Replace Characters to Left of a String with Another String/Character

    4 char - space - text
    or
    8 char - space - text
    ?

  5. #5
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Replace Characters to Left of a String with Another String/Character

    Well that is the format of the data in the existing cells so technically the input pre code execution but yes, always same format.

  6. #6
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Replace Characters to Left of a String with Another String/Character

    You can ignore, managed to work it out. Thanks for your assistance.

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Replace Characters to Left of a String with Another String/Character

    Care to share your solution with the board?

  8. #8
    Forum Contributor
    Join Date
    04-11-2017
    Location
    Edinburgh, Scotland
    MS-Off Ver
    2010
    Posts
    110

    Re: Replace Characters to Left of a String with Another String/Character

    Apologies for very late response.

    Please Login or Register  to view this content.

  9. #9
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Replace Characters to Left of a String with Another String/Character

    Thanks for sharing

+ 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 EACH Nth occurrence a character in a string with another character
    By mattman7 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-23-2016, 12:23 PM
  2. [SOLVED] VBA string manipulation, move '_' to one character left
    By boon-yao.tek in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-16-2016, 06:13 AM
  3. [SOLVED] Extract left characters from string with exception of 2 right characters
    By sweetkel23 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-16-2012, 10:45 PM
  4. Replies: 6
    Last Post: 06-21-2012, 11:40 AM
  5. [SOLVED] Sum numbers left of a character from within a string
    By BarryTSL in forum Excel General
    Replies: 14
    Last Post: 04-17-2012, 01:11 PM
  6. Truncating part of string to the left of a character
    By UrbanEast in forum Excel General
    Replies: 4
    Last Post: 12-12-2010, 02:37 AM
  7. [SOLVED] Extracting a character from a string of characters
    By Sue in forum Excel General
    Replies: 6
    Last Post: 10-29-2005, 09:05 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