+ Reply to Thread
Results 1 to 4 of 4

Excel VBA Change text colour depending on another cell's content

  1. #1
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Excel VBA Change text colour depending on another cell's content

    I have absolutely no experience in VBA;

    I am using Excel 2002 and have a spreadsheet comprising columns A – BI and rows 1-900

    Entries in column O can be C, N, RC, RN

    I have been trying to write a code so that –

    If Columns O = C and J is a date in the future, then Column C will automatically be populated with “CW” and the whole of the row will be in dark green text

    If Columns O = “C” and J is today or a date in the past, then Column C will automatically be populated with “C” and the whole of the row will be in red text

    If Columns O = “N” and P is blank, then Column C will automatically be populated with “W” and the whole of the row will be in dark blue text

    If Columns O = “N” and P has a date in it, then Column C will automatically be populated with “E” and the whole of the row will be in black text

    If Columns O = “RC” or “RN” and L is blank, then Column C will automatically be populated with “W” and the whole of the row will be in dark blue text

    If Columns O = “RC” and L has a date in it, then Column C will automatically be populated with “C” and the whole of the row will be in red text

    If Columns O = “RN” and L has a date in it, then Column C will automatically be populated with “E” and the whole of the row will be in black text

    Any other entries should default to black text

    All of the above to be non-case sensitive.

    I’ve managed, almost, to get this to work using an IFAND function and conditional formatting but would rather use VBA because this would prevent any other users from meddling with the functionality.

    Lastly can anyone suggest a good site for gaining an understanding of how to write VBA procedures, one that will explain things as if I am a simpleton and use words of not more than 2 syllables

    Appreciate any suggestions

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Excel VBA Change text colour depending on another cell's content

    Hello Jell,

    This macro will format the row text based on what is in cell "O". Change the worksheet name to what you are using. I was not sure if the last letter after the "B" was "L" or "I" because of the font. Change that if it it isn't right before you run the macro.
    Please Login or Register  to view this content.
    Last edited by Leith Ross; 02-08-2010 at 08:48 PM.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    02-08-2010
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Excel VBA Change text colour depending on another cell's content

    Leith, Thanks, I haven't had a chance to try this on Excel2002, but I have on 2003, unfortunately it doesn't work. I noticed a spelling mistake on your last line but correcting it has made no difference. The macro runs but doesn't update column c

    Any suggestions, Thanks, Jell

  4. #4
    Forum Contributor
    Join Date
    02-04-2010
    Location
    Hertfordshire, England
    MS-Off Ver
    Office 2007 (home) Office 365 (work)
    Posts
    134

    Re: Excel VBA Change text colour depending on another cell's content

    Hi Jell

    I think you just need to correct this bit of the code

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    so that column O is evaluated

    also to update Column C you need to add the line

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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