+ Reply to Thread
Results 1 to 5 of 5

Highlighting single word in text string gone wrong

  1. #1
    Registered User
    Join Date
    10-15-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2013
    Posts
    2

    Highlighting single word in text string gone wrong

    I have a problem when I want to only highlight certain words in a text string where it does not highlight all of the words in the string.

    I'm using this VBA code, which I found in this forum but found out that the words needs to be in the correct order for the words to be highlighted.

    For instance if a cell contains the text "this is a test"
    And I want to highlight "test" and "is" - if I write it in this order in the code it will only highlight "test"

    Can anybody help?
    Attached Files Attached Files

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,532

    Re: Highlighting single word in text string gone wrong

    Welcome to the Forum EDBComputer123 !

    When providing VBA code, please do not put the code in a separate file and upload the file. It is easier for both you and us to put the code directly in your post, using code tags:

    Please Login or Register  to view this content.
    This code is a bit dense so I am not able to give you an answer immediately, but I will take a look if nobody else beats me to it.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,464

    Re: Highlighting single word in text string gone wrong

    https://www.excelforum.com/excel-gen...ml#post2958563

    Change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Highlighting single word in text string gone wrong

    Here's a slighly different approach

    Create two range names
    Data:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    I'm assuming your text is in columns A & B

    lstWords:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    where column E contains a list of all the words you want to colour.

    Then run the following macro

    Please Login or Register  to view this content.
    See attached
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  5. #5
    Registered User
    Join Date
    10-15-2019
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2013
    Posts
    2

    Re: Highlighting single word in text string gone wrong

    Thanks guys. Both solutions works perfectly fine and just what I needed - thanks!

+ 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. Highlighting duplicates as well as another single cell and inputting text
    By Southie89 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-02-2018, 01:35 PM
  2. Highlighting a row that contains text other than one word
    By snwbrdr19 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-17-2017, 03:49 PM
  3. [SOLVED] Match single word to string of text
    By Seraph84 in forum Excel General
    Replies: 6
    Last Post: 02-24-2016, 03:37 AM
  4. Change the colour of single word in text string based on another cell value
    By joshnathan in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-03-2014, 09:41 AM
  5. Replies: 2
    Last Post: 02-06-2013, 12:13 AM
  6. Replies: 0
    Last Post: 02-05-2013, 07:51 AM
  7. Highlighting single Text in excel sheet by macro
    By NM123 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 11-15-2011, 06:29 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