Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default Q: How to change tab color based on cell value

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default How to change tab color based on cell value

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change tab color based on current color of a cell MarkT Excel Discussion (Misc queries) 0 May 22nd 08 05:46 PM
Can a cell change color based on the value of another? Woodenkettle Excel Discussion (Misc queries) 2 June 7th 07 10:15 PM
Can you change the color of one cell based on the color of another andoscott Excel Discussion (Misc queries) 4 May 4th 07 04:02 PM
Excel: Syntax to change cell color based on color of another cell davew18 Excel Worksheet Functions 1 January 4th 07 01:24 PM
Change tab color based on a cell value Zenaida Excel Discussion (Misc queries) 14 April 27th 06 10:35 PM


All times are GMT +1. The time now is 01:19 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"