+ Reply to Thread
Results 1 to 9 of 9

Highlight different words in different colors

  1. #1
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Highlight different words in different colors

    Hello,
    I am looking for a macro to highlight in a MS Word document different words in different colors using a userform or search box.
    Any help would be highly appreciated!
    N

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Highlight different words in different colors

    Is there a reason you can't just use Find/Replace for this?
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Highlight different words in different colors

    Because I have many keywords and their synonyms and I would like to search and highlight them in different colors at once.
    N

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Highlight different words in different colors

    The following macro uses Find/Replace on three different arrays to variously highlight/un-highlight and change the highlight colour of a range of words & strings.
    Please Login or Register  to view this content.
    Simply replace the array terms with your own for the word and its synonyms and change the highlight settings to whatever you'd prefer. You can also add more of the array & For ... Next blocks.

  5. #5
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Highlight different words in different colors

    Hi,
    I really appreciate your help. I was wondering whether this could be also soved by using a textbox (see image) where 5 different highlighting colors would be assigned to the 5 different groups of words.
    Thank you so much in advance
    N
    Textbox.PNG

  6. #6
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Highlight different words in different colors

    Yes, that could be done, but the code would have to be completely re-written around the use of a userform. Furthermore, your form mockup doesn't provide for the user to choose the highlight colour for any of the options.

    For flexibility, without the need for a userform, try:
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Highlight different words in different colors

    Hi ,
    I think, for this purpose, the use of a userform would be mre appropriate, since I can have 5 different groups of words, and all words within a group must have a same color.
    The user doesn't need to choose a color, because the color of the different groups will be fixed, i.e for the group 1 we use "yellow", for the group 2 "Bright Green", for the group 3 "Turquoise", for the group 4 "Pink", for the group 5 "Gray 50".
    Thanks very much for trying to write the code around a userform.
    N

  8. #8
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Highlight different words in different colors

    Quote Originally Posted by Niclal View Post
    I think, for this purpose, the use of a userform would be mre appropriate, since I can have 5 different groups of words, and all words within a group must have a same color.
    That's all well and good, but I wasn't proposing to do the userform work - I have plenty else to do. The code I've posted already allows you to do one group at a time, without the need for a userform.

  9. #9
    Forum Contributor
    Join Date
    10-06-2012
    Location
    Basel, Switzerland
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: Highlight different words in different colors

    I can imagine that you don't have the time, I fully understand that, and that's why I am asking for a bit of help with the userform, and I will then finish it.
    Much appreciated!

+ 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. Different Colors for Rows With Key Words
    By KGBerry in forum Excel General
    Replies: 3
    Last Post: 06-21-2012, 11:30 AM
  2. Replies: 1
    Last Post: 07-15-2010, 08:20 PM
  3. Highlight cell with many words, with duplicates from row with single words.
    By Meows in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2010, 08:27 PM
  4. Highlight Cells Different Colors
    By juliajd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-06-2009, 09:03 PM
  5. Highlight a row without losing background colors
    By Naceur in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-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