+ Reply to Thread
Results 1 to 4 of 4

replace doesn't search for the entire word before replacing

  1. #1
    Registered User
    Join Date
    06-23-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    9

    replace doesn't search for the entire word before replacing

    I have a code below that matches each individual word in the title in column A with words in sheet 2 column E and then replacing those words with the words in column F array. However I have encountered a difficultly, when there are similar words, the matching works by matching the shorter word instead of the full longer word. For example the array contains Small:SM and Smaller:SM however my title of A smaller cow will be replaced to A SMer cow. How do I get the code to match the entire word smaller instead of just small?




    Please find attached a sample file with the code.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: replace doesn't search for the entire word before replacing

    Replace (in your code)
    Please Login or Register  to view this content.
    By
    Please Login or Register  to view this content.

  3. #3
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: replace doesn't search for the entire word before replacing

    For that specific situation, you just need to make sure that Smaller appears above Small in the replacement table. If you only want whole word matches, you'll need to revise the code quite a lot - especially if you have punctuation to take into account.
    Remember what the dormouse said
    Feed your head

  4. #4
    Registered User
    Join Date
    06-23-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    9

    Re: replace doesn't search for the entire word before replacing

    Reordering the replacement table does help. However, if i wanna replace - with a space it doesn't work . Do I have to edit the code?

+ 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. Replies: 2
    Last Post: 04-29-2014, 10:06 AM
  2. How to search for a word in a column and have entire row opaque once word is found
    By copleyr in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 09-04-2009, 07:11 PM
  3. How do I replace the last entire word in text cells?
    By George in forum Excel General
    Replies: 7
    Last Post: 12-15-2005, 05:35 PM
  4. Replies: 5
    Last Post: 09-13-2005, 07:06 AM
  5. [SOLVED] How to Search for word in the Entire Workbook
    By lbbss in forum Excel General
    Replies: 4
    Last Post: 07-04-2005, 04: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