+ Reply to Thread
Results 1 to 11 of 11

Change tab color depending on cell value

  1. #1
    Registered User
    Join Date
    11-04-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2007
    Posts
    7

    Cool Change tab color depending on cell value

    I am trying to use vba (excel 2007) to change the tab color depending on the value of a specific cell.

    Example: Change tab color to red, if cell A1 = <2.5. Change tab color to green, if cell A1 = >2.5 but <4.

    Any ideas?

    Ryan
    Last edited by rirons04; 11-04-2010 at 09:35 PM.

  2. #2
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Change tab color depending on cell value

    Copy this code to the worksheet module. It triggers when the value of A1 is changed.
    Sheet name used below is the sheet code name. Change the name as needed.'

    Please Login or Register  to view this content.
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  3. #3
    Registered User
    Join Date
    11-04-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Change tab color depending on cell value

    Thank you for the quick response. I have inserted the code and changed the tab name, but it does not seem to be working. I am not receiving any error messages, but it isn't changing anything.

    ~Ryan

  4. #4
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Change tab color depending on cell value

    The code works fine for me. Did you put in the worksheet module?

    Right-click the sheet tab > View Code > Copy and paste the above code.

    As I stated in my post I am using the sheet code name - not the worksheet (tab) name - so you probably need to change the VBA code to use the actual sheet code name.

    However, here is another version that doesn't require you to make the change to the sheet code name.
    Please Login or Register  to view this content.
    Last edited by Palmetto; 11-04-2010 at 09:53 PM. Reason: revised code per OP post

  5. #5
    Registered User
    Join Date
    11-04-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Change tab color depending on cell value

    Thank you, that works perfectly.

  6. #6
    Registered User
    Join Date
    11-04-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Change tab color depending on cell value

    I just realized one other small issue. Is there a way to change this back to "no color" if the cell = > 4?

    ~Ryan

  7. #7
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Change tab color depending on cell value

    Code revised per request in previous post.

  8. #8
    Registered User
    Join Date
    11-04-2010
    Location
    Milwaukee, WI
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Change tab color depending on cell value

    Thank you again for your help.

    ~Ryan

  9. #9
    Registered User
    Join Date
    12-14-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Change tab color depending on cell value

    How would you modify this code to pertain to date? For instance if the cell value is blank tab would be red, if a date is populated turn the tab green? I'm using Cell A10. Thanks for any assistance!

  10. #10
    Registered User
    Join Date
    12-14-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Change tab color depending on cell value

    Hi all, I am trying to figure out how to make the tabs on the spreadsheet go from red to green once a date is entered into cell A10. I'm very new to VBA, so any help is greatly appreciated!

    Thanks,
    Lisa

  11. #11
    Registered User
    Join Date
    03-01-2011
    Location
    Savannah, GA
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Change tab color depending on cell value

    I have tried all of the code suggested below and cannot get this to work in a similar spreadsheets I am working on. I would like the tab color to change to green if a particular cell (calculated) value changes from 0 to 1 and reverts back to red if changed back to 0. I have been inserting this code into a single worksheet module to test. I get a run time error, which when I elect to debug, shows it stopping at the line where the change event is supposed to occur (i.e. .Tab.Color = vbRed, or any other version of this tried). I am using 2007.

    Any help would be greatly appreciated!

+ 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