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
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.
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.
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
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
Thank you, that works perfectly.
I just realized one other small issue. Is there a way to change this back to "no color" if the cell = > 4?
~Ryan
Code revised per request in previous post.
Thank you again for your help.
~Ryan
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!
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
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!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks