LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Return cell(s) Conditional Formatting Status via a macro

Using a macro, I would like to read the Conditional Formatting status of
cells so that I can, for example: color a sheets tab red if any cells on the
sheet are out of range based on their conditional format status. Attached is
code that I thought would do the trick. It works if I manually set the cells
to colors 3 or 45, but always returns -4142 if cell colors are set via
Conditional Formatting.

Sub Sheet1_ColorCellsTest()
Dim redcells As Integer
Dim orangecells As Integer
redcells = 0
orangecells = 0
For Each c In Worksheets("Sheet1").Range("D7,E12:E44").Cells
Select Case c.FormatConditions(1)
Case 3 '3 red
redcells = redcells + 1
Case 45 '45 orange
orangecells = orangecells + 1
Case Else 'Not red or orange
redcells = redcells
orangecells = orangecells
End Select
Next
If redcells 0 Then
Sheets("Sheet1").Tab.ColorIndex = 3 'If any red, make tab red 3, done
Else
If orangecells 0 Then
Sheets("Sheet1").Tab.ColorIndex = 45 'Or if any orange, make tabe
orange 45, done
Else
Sheets("Sheet1").Tab.ColorIndex = 50 'Else if any No color, make tab
green 50, done
End If
End If
End Sub



 
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
Conditional formatting based on text status of 3 cells Sandy82 Excel Discussion (Misc queries) 5 March 8th 09 04:33 PM
Conditional formatting: colored bar with pointer on current status Hannes Excel Discussion (Misc queries) 0 November 20th 07 08:50 AM
Return adjacent cell if conditional formatting exists. Donna Excel Worksheet Functions 12 November 10th 06 04:34 AM
Conditional Formatting Need to Return to Zero KB Excel Worksheet Functions 3 July 26th 06 10:45 PM
Conditional formatting a #N/A return in a cell? I want it white. Wendy Excel Discussion (Misc queries) 2 January 27th 06 06:55 PM


All times are GMT +1. The time now is 12:32 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"