+ Reply to Thread
Results 1 to 15 of 15

Change Font Color in a Range based on One Cells information

  1. #1
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Change Font Color in a Range based on One Cells information

    I have attached an example file.. Basically I want the text in a range to change to red if one cell="Description".

    Also, I want a cell's text to turn blue if it's corresponding data in the row says "Click on Title to Follow Link"

    The example file explains it a lot better..

    Thanks for the help.. Sorry if this may seem like a duplicate post but I was not able to get any of the examples I searched for to work that others have posted.. Also, maybe conditional formatting would be an option here but I could not get it to work as it will only meet the first condition that comes across thats true...

    Thanks again!
    Attached Files Attached Files
    Last edited by mrgillus; 07-28-2009 at 11:54 AM.

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Change Font Color in a Range based on One Cells information

    If you don't mind VB solution you can put this into the Sheet code area, (click on the tab of the sheet and 'View Code' then paste this in)

    Please Login or Register  to view this content.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Re: Change Font Color in a Range based on One Cells information

    Thanks for the prompt reply Phil... I tried to paste this in, however it throws an error on the highlighted line.

    Please Login or Register  to view this content.
    The error is "Run-time error '1004':
    Unable to set the ColorIndex property of the Font Class
    Last edited by mrgillus; 07-28-2009 at 09:50 AM. Reason: Can't spell

  4. #4
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Change Font Color in a Range based on One Cells information

    Strange...

    So working on your example workbook;

    I download and open it.
    Right click on the tab [Sheet1 (2)] and select 'View code' from the popup menu.
    Paste the code as given above into the VBA editor window that opens.
    Use the Summaries / Description dropdown box to change the value and all works.

    Is that the same as you are doing?

  5. #5
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Re: Change Font Color in a Range based on One Cells information

    My apologies as I am actually pasteing it in another work book.. Although both are set up the same way using the same formulas etc.. That is bazaar.. Usually I don't have any problems transferring to my functional workbook from an example..

    Is it possible that having other code on the same sheet would cause this to mess up?
    Please Login or Register  to view this content.
    It is very possible that I have that setup wrong.. ..

    If need be I will wipe the data of my functional workbook and upload that instead..

  6. #6
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Re: Change Font Color in a Range based on One Cells information

    Well here is the official- Minus the important stuff that is.. Basically I am trying to get the colors to change in the "List" Tab. You can click on the Description Cell which is in dark green to select between "Description" and "Summary".

    I should have just uploaded it this way initially but thought it would be more time consuming..

    Let me know what you think..

    Thanks
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Change Font Color in a Range based on One Cells information

    You will need to make the following changes, as you can't change the Font's ColorIndex if the sheet is protected which is one of the things your other macro is doing

    Please Login or Register  to view this content.
    Hopefully that will sort it out

  8. #8
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Re: Change Font Color in a Range based on One Cells information

    Right.. Let me give that a try.. I definitely didn't think about that..

  9. #9
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Re: Change Font Color in a Range based on One Cells information

    Yup.. Now it work's perfectly.. Maybe you can reference my Example file for the question where I want to change the Title to Blue if the corresponding description in the row says "Click on Title to Follow Link"? Thanks for your help..




    Quote Originally Posted by mrgillus View Post
    I have attached an example file.. Basically I want the text in a range to change to red if one cell="Description".

    Also, I want a cell's text to turn blue if it's corresponding data in the row says "Click on Title to Follow Link"
    The example file explains it a lot better..

    Thanks for the help.. Sorry if this may seem like a duplicate post but I was not able to get any of the examples I searched for to work that others have posted.. Also, maybe conditional formatting would be an option here but I could not get it to work as it will only meet the first condition that comes across thats true...

    Thanks again!

  10. #10
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Change Font Color in a Range based on One Cells information

    This isn't actually relevant to your question, but I would recommend assigning that password to a variable (or constant) and then using that variable in your Protect/Unprotect code. Makes it easier to change it!
    Remember what the dormouse said
    Feed your head

  11. #11
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Change Font Color in a Range based on One Cells information

    try this done with conditional format
    Attached Files Attached Files
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  12. #12
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Re: Change Font Color in a Range based on One Cells information

    Yup that does the trick!

    Thanks a bunch for your guys' help!

    Much appreciated

  13. #13
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Post Re: Change Font Color in a Range based on One Cells information

    Here is revised code, using a CONST for the password, and also for the colorindex's for easy reuse.

    Please Login or Register  to view this content.
    One point though;
    I've used the text you had in your post;
    Also, I want a cell's text to turn blue if it's corresponding data in the row says "Click on Title to Follow Link"
    but that is NOT what current appears in the cells being checked;
    Click Title for Description
    I wasn't sure which would be right in the end, so figured I'd point it out and you can correct it as needed

    EDIT I like Martin's solution, no worries about macro security then, and might/could be faster

  14. #14
    Forum Contributor
    Join Date
    07-08-2009
    Location
    Missouri
    MS-Off Ver
    Excel 2003
    Posts
    183

    Re: Change Font Color in a Range based on One Cells information

    Thanks once again guys! This was a great help!

  15. #15
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: Change Font Color in a Range based on One Cells information

    Note that there is a small mistake in my code, about 5 lines from the end.
    The line:
    Please Login or Register  to view this content.
    Should read:
    Please Login or Register  to view this content.
    Otherwise it will adjust the font colour of the cells in Column D instead of in C


+ 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