+ Reply to Thread
Results 1 to 10 of 10

keyword search - a macros to change font color for specific key words (not entire cell)

  1. #1
    Registered User
    Join Date
    05-02-2014
    Location
    orange county, california
    MS-Off Ver
    Excel 2010
    Posts
    5

    keyword search - a macros to change font color for specific key words (not entire cell)

    Hi,

    so my issue is this: i need to conduct keyword searches in excel and color the keywords a different color without changing the font color of the entire cell. now, i found some code from another thread that does this, but i cant seem to get it to work with more than 2 keywords. i need some help fine-tuning the provided code to do what i need it to do.

    please see: http://www.excelforum.com/excel-gene...ain-color.html

    the VBA code i used was this:

    Please Login or Register  to view this content.
    i was playing around with the example, the Cat_Mouse.xlsm, and when i modified the 'myList' and 'myColor' arrays, it does not work.

    Cat_Mouse.xlsm

    for example, i modified the code to add the word bat:

    Please Login or Register  to view this content.
    when i run the macros, the word "Bat" does not become colored red. interestingly enough, when i substitute the word "bat" for the word "hat" in the "myLIST array, the word "hat" does change to the red font. any ideas on why this is happening?

    i am looking to use this code to address keywords in my excel file by coloring all key words red and i have more than 10 key words.

    any help would be appreciated, thanks.

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    kingwhopper,

    You want to look at the below link:

    Sub ColorCertainWords()
    ' Rick Rothstein, MrExcel MVP, 05/02/2014
    http://www.mrexcel.com/forum/excel-q...lls-excel.html
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    05-02-2014
    Location
    orange county, california
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    excellent find, stanleydgromjr!

    i decided to use this code:

    Please Login or Register  to view this content.
    my question is how do i edit this code to work not only in column B but also column H (ie, look for all keywords in columns B and H)

    would be really nice if i could figure out a way to modify this code to fit my needs. this code should alow me to paste my keywords in a separate sheet

    Please Login or Register  to view this content.

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

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-02-2014
    Location
    orange county, california
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    Quote Originally Posted by jindon View Post
    Please Login or Register  to view this content.
    hi Jindon,

    thanks for your response. if i use that code, i still cant add more than 2 keywords to be searched. any ideas?

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

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    You should be able to add as many as you want.

    e.g
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-02-2014
    Location
    orange county, california
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    how do i modify the code so that if my keyword was "cat" and my spreadsheet had the word "Cats" that it would show up as Cats

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

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    Try change the pattern to
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    05-10-2013
    Location
    Pomáz, Hungary
    MS-Off Ver
    Excel 2007
    Posts
    78

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    This macro was created to format substrings in a selected range of cells in a single step:

  10. #10
    Registered User
    Join Date
    04-08-2014
    Location
    hk
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: keyword search - a macros to change font color for specific key words (not entire cell

    hi,how to extract the highlighted keywords(e.g. cat,mouse) in the column J?
    For example:
    Column B Column J
    Cats123 Cat
    002Mouse123 Mouse
    Mickey Mouse Mouse

    Regards

+ 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: 28
    Last Post: 08-29-2013, 02:53 PM
  2. Change the font color to black in the entire workbook
    By fatalcore in forum Excel General
    Replies: 2
    Last Post: 03-31-2011, 02:30 AM
  3. Change font/color for entire row using OR statement
    By BuffaloSS in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2011, 06:35 PM
  4. [SOLVED] change font color on search
    By frogtoad123 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-28-2005, 01:50 PM

Tags for this Thread

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