Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Count Red Cells on a worksheet

I am looking for a way to count the number of Red Cells on a worksheet and
return that number is a message box. Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Count Red Cells on a worksheet

Something along these lines should work.

If cells are colored by conditional format:

For Each c In myRange
If c.FormatConditions.Interior.ColorIndex = 3 Then
'Do something
End If

If cells are colored by standard format or code:

For Each c In myRange
If c.Interior.ColorIndex = 3 Then
'Do something
End If

"Aaron" wrote:

I am looking for a way to count the number of Red Cells on a worksheet and
return that number is a message box. Thanks in advance!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Count Red Cells on a worksheet

You realize, of course, that is not complete code.

"Aaron" wrote:

I am looking for a way to count the number of Red Cells on a worksheet and
return that number is a message box. Thanks in advance!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Count Red Cells on a worksheet

Here is code that will work if the cells are red by standard format method.

Sub cntclr()
Count = 0
For Each C In Worksheets(1).Range("A1:F20") 'Change range for needs.
If C.Interior.ColorIndex = 3 Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

"Aaron" wrote:

I am looking for a way to count the number of Red Cells on a worksheet and
return that number is a message box. Thanks in advance!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Count Red Cells on a worksheet

What if it is a conditional formatting that turns the cell red??

"JLGWhiz" wrote:

Here is code that will work if the cells are red by standard format method.

Sub cntclr()
Count = 0
For Each C In Worksheets(1).Range("A1:F20") 'Change range for needs.
If C.Interior.ColorIndex = 3 Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

"Aaron" wrote:

I am looking for a way to count the number of Red Cells on a worksheet and
return that number is a message box. Thanks in advance!



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Count Red Cells on a worksheet



"Aaron" wrote:

What if it is a conditional formatting that turns the cell red??



In that case you just insert the FormatConditions property like:

Sub cntclr()
Count = 0
For Each C In Worksheets(1).Range("A1:F20") 'Change range for needs.
If C.FormatConditions.Interior.ColorIndex = 3 Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub






"JLGWhiz" wrote:

Here is code that will work if the cells are red by standard format method.

Sub cntclr()
Count = 0
For Each C In Worksheets(1).Range("A1:F20") 'Change range for needs.
If C.Interior.ColorIndex = 3 Then
Count = Count + 1
End If
Next
MsgBox Count
End Sub

"Aaron" wrote:

I am looking for a way to count the number of Red Cells on a worksheet and
return that number is a message box. Thanks in advance!

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
how to count#cells w/= value in other column and not count blank c aganoe Excel Worksheet Functions 4 April 9th 10 11:36 AM
How to count two cells occurrences in a worksheet ben mustapha Excel Worksheet Functions 3 November 8th 08 04:45 PM
how to count non blank cells from another worksheet Anne Excel Discussion (Misc queries) 1 August 5th 08 08:31 AM
Count of Worksheet rows and recording this count mikerobe Excel Programming 2 March 21st 07 02:17 AM
Using the COUNT funciton to count cells with values wjsubs[_5_] Excel Programming 4 July 9th 04 05:00 PM


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