Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Using VBA and Excel 2002, how can I change a tab color whenever any
cell on that tab/sheet has its interior color becomes equal to index 4 (green)? What I'm trying to accomplish: Cells on a sheet contain conditional formatting that when given a certain condition will change the interior color of that cell to green. This workbook contains many sheets...so to make it quicker to find those green cells, the related tab will also change to green. Any ideas? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
the bad news is that you can't invoke a macro directly triggered by the color change of a conditional format. In addition you're not able to read the colorindex of a conditional formated cell in VBA (.interior.colorindex will always return the colorindex of the default color whether the condition is met or not). One workaround: You can use the worksheet_change event and check the conditions programmatical. That is you reprogram the conditions of your conditional format. e.g. Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count 1 Then Exit Sub If Intersect(Target, Me.Range("A1:A100")) Is Nothing Then Exit Sub On Error GoTo CleanUp: With Target If .Value = 1 Then 'change this to your conditions Application.EnableEvents = False Activesheet.Tab.ColorIndex = 4 End If End With CleanUp: Application.EnableEvents = True End Sub this test if a cell in the range A1:A100 is '1' and if yes changes the tab color to green -- Regards Frank Kabel Frankfurt, Germany John wrote: Using VBA and Excel 2002, how can I change a tab color whenever any cell on that tab/sheet has its interior color becomes equal to index 4 (green)? What I'm trying to accomplish: Cells on a sheet contain conditional formatting that when given a certain condition will change the interior color of that cell to green. This workbook contains many sheets...so to make it quicker to find those green cells, the related tab will also change to green. Any ideas? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Change tab color based on current color of a cell | Excel Discussion (Misc queries) | |||
Can a cell change color based on the value of another? | Excel Discussion (Misc queries) | |||
Can you change the color of one cell based on the color of another | Excel Discussion (Misc queries) | |||
Excel: Syntax to change cell color based on color of another cell | Excel Worksheet Functions | |||
Change tab color based on a cell value | Excel Discussion (Misc queries) |