PC Review


Reply
Thread Tools Rate Thread

Count Red Cells on a worksheet

 
 
=?Utf-8?B?QWFyb24=?=
Guest
Posts: n/a
 
      16th Nov 2007
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 With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      16th Nov 2007
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!

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      16th Nov 2007
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!

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      16th Nov 2007
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 With Quote
 
=?Utf-8?B?QWFyb24=?=
Guest
Posts: n/a
 
      16th Nov 2007
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!

 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      16th Nov 2007


"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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count contiguous cells, or count cell clusters BizoNo Microsoft Excel Worksheet Functions 0 16th Feb 2010 07:06 PM
How to count two cells occurrences in a worksheet ben mustapha Microsoft Excel Worksheet Functions 3 8th Nov 2008 04:45 PM
how to count non blank cells from another worksheet Anne Microsoft Excel Misc 1 5th Aug 2008 08:31 AM
Count of Worksheet rows and recording this count mikerobe Microsoft Excel Programming 2 21st Mar 2007 02:17 AM
Excel 2007. BUG. Count is defined as a long. Cells.Count results in error Overflow keepITcool Microsoft Excel Crashes 4 6th Jul 2006 10:14 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:33 PM.