+ Reply to Thread
Results 1 to 5 of 5

Macro to change font color based on contents of another column

  1. #1
    Registered User
    Join Date
    01-07-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Macro to change font color based on contents of another column

    Hi. I can't figure this out even after searching this forum with keywords such as "font color change macro"

    I have text in Column D. It consists of phrases such as:
    JUL 2009 EXAM
    FEB 2009 EXAM
    JUL 2009 LIST
    FEB 2009 LIST
    JUL 2009 OUTLINE
    FEB 2009 OUTLINE

    I need a macro to change the font color of the text in Column B of each row based on the text in Column D. If the text in column D contains the word "EXAM", the text in Column B for that row should be Red and bold. If the text in column D contains the word "LIST", the text in Column B for that row should be Blue and bold. If the text in column D contains the word "OUTLINE", the text in Column B for that row should be Green and bold. I know I can do this with conditional formatting, but it must be a macro that actually changes the properties of the text in Column B since I use Excel spreadsheets to do batch search and replaces in Word documents with a program called Useful File Utilities and it does not recognize the conditional formatting. I only want to change the font color for text in Column B. The other columns should stay the same. Thanks.
    Last edited by Pat Parker; 03-28-2010 at 12:34 AM.

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: Macro to change font color based on contents of another column

    Just for a start:
    Please Login or Register  to view this content.
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    01-07-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Macro to change font color based on contents of another column

    Quote Originally Posted by protonLeah View Post
    Just for a start:
    Please Login or Register  to view this content.
    Thanks for the reply. The macro starts to change the colors for the first item ("EXAM") and then I get a runtime error. I forgot to mention that not all rows in column D contain text - some are blank. I believe this is the reason for the runtime error. Do you know how I can ignore blank fields in Column D?

    I then created a small sample with no blank cells in Column D. The macro does "EXAM" correctly but does not process the other two items ("LIST" and "OUTLINE").

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,604

    Re: Macro to change font color based on contents of another column

    Please do not quote prior posts.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-07-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    38

    Re: Macro to change font color based on contents of another column

    Thanks! It works great!

+ 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