+ Reply to Thread
Results 1 to 7 of 7

Macro to remove certain text string ONLY if comes at first

  1. #1
    Registered User
    Join Date
    10-19-2012
    Location
    Egypt
    MS-Off Ver
    Excel 2003
    Posts
    40

    Macro to remove certain text string ONLY if comes at first

    Hi,

    I need a macro that helps me check a column of text against a list of given words, remove these words from column cells ONLY when they come at the very first of the cell

    Example:
    I need to remove the word "learn" from a list of course titles in a column (A2: A100) - only when "learn" show up in the beginning:

    learn how to design robots ---------->how to design robots

    While if "learn" show up in any other part (middle, or last word):

    Explore and learn how to design robots --------> stays the same
    Robots designs: Where to learn----------> stays the same


    Any help with that?
    Thanks in Advance

  2. #2
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Macro to remove certain text string ONLY if comes at first

    How about this:
    Please Login or Register  to view this content.
    Requires you select the range to be operated on first. If you wanted, you could hard-wire that.

  3. #3
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Macro to remove certain text string ONLY if comes at first

    The above doesn't use a list; the one below does:
    Please Login or Register  to view this content.
    You need to specify your list of words to be replaced in D2:D6, or revise the macro to point to the correct address.

  4. #4
    Registered User
    Join Date
    10-19-2012
    Location
    Egypt
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Macro to remove certain text string ONLY if comes at first

    It works exactly the way I need!

    Thanks a million gjcase
    Last edited by jeffreybrown; 07-13-2013 at 10:40 AM. Reason: As per Forum Rule #12, please don't quote whole post unless necessary -- it's just clutter.

  5. #5
    Registered User
    Join Date
    10-19-2012
    Location
    Egypt
    MS-Off Ver
    Excel 2003
    Posts
    40

    Re: Macro to remove certain text string ONLY if comes at first

    One more thing gjcase..
    I wonder how would this code look like if -instead of removing "learn ", adding "ing" to it to become "learning"? Still when comes at first of sentence only
    I'd appreciate your response..

    Thanks a lot

  6. #6
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Macro to remove certain text string ONLY if comes at first

    Here you are:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    08-08-2005
    Location
    Kansas, USA
    MS-Off Ver
    2016
    Posts
    293

    Re: Macro to remove certain text string ONLY if comes at first

    Here you are:
    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)

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