Ask Experts Questions for FREE Help!
  Advanced
Register  |  Log in  
   Ask    
 Answer  
  Help  

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Computers & Technology > Software > Spreadsheets   »   Excel count function

 
Thread Tools Display Modes
Question
 
 
#1  
Old Apr 7, 2004, 10:16 AM
fyogi1
New Member
fyogi1 is offline
 
Join Date: Apr 2004
Location: Denver, CO
Posts: 5
fyogi1 See this member's comment history on his/her Profile page.
Send a message via ICQ to fyogi1
Excel count function

I am trying to count a large group of cells that are colored depending on the data. For example: I want to count the number of red cells which are faults. I tried the countif but not sure how to set the criteria.

Thanks for any help.

Reply With Quote
 
     

Answers
 
 
Old Apr 7, 2004, 03:03 PM   #2  
Senior Member
retsoksirhc is offline
 
retsoksirhc's Avatar
 
Join Date: Mar 2004
Location: Michigan
Posts: 741
retsoksirhc See this member's comment history on his/her Profile page.
Send a message via AIM to retsoksirhc
Re: Excel count function

Heres the basic syntax

=countif(cells, condition)

so you would take whatever you are calculating as a fault and put that under the conditions part (for example, <5). The cells are whichever ones you are trying to count with (ie. a1:e5). Assign this to a cell being sure to have an = at the beginnging to show that it is a calculation, and that cell will show the number of cells in a1:e5 that are <5.
  Reply With Quote
 
     
 
 
Old Apr 8, 2004, 06:22 AM   #3  
New Member
fyogi1 is offline
 
Join Date: Apr 2004
Location: Denver, CO
Posts: 5
fyogi1 See this member's comment history on his/her Profile page.
Send a message via ICQ to fyogi1
Re: Excel count function

Thanks for your response. I got that far but I want to set the condition as the color, not a number or text in the cell. I have a workbook with multiple cells filled in with different colors. I want to count certain color of cells.
  Reply With Quote
 
     
 
 
Old May 6, 2004, 11:57 PM   #4  
New Member
Dreamboat is offline
 
Dreamboat's Avatar
 
Join Date: May 2004
Location: Quakertown, PA
Posts: 22
Dreamboat See this member's comment history on his/her Profile page.
Re: Excel count function

Hi, fyogi1.

This requires a user-defined function (UDF). Check out Chip Pearson's site:
http://www.cpearson.com/excel/colors.htm

I'm sure it's a bit late, but you'll have it for next time.
  Reply With Quote
 
     
 
 
Old Nov 18, 2004, 01:53 PM   #5  
New Member
leif5233 is offline
 
Join Date: Nov 2004
Posts: 2
leif5233 See this member's comment history on his/her Profile page.
Try this code

Create this function:

Function CountCol(SumRange As Range, intColor As Integer) As Integer
Dim i As Integer
Dim Cell As Range

Set SumRange = SumRange.SpecialCells(xlCellTypeAllFormatCondition s)

For Each Cell In SumRange
If Cell.Interior.ColorIndex = intColor Then
i = i + 1
End If

Next Cell

CountCol = i

End Function

Then in the cell where you would like the total, put the following formula:

=CountCol(a1:a100,6)

That formula will show you the total count of all cells with colorindex of 6 (Yellow) in range a1:a100. You can fix it up to use color names if you like, but this works fine for me. There is a listing of basic colorindexes in Excel's help.

Hope this helps,
Leif
  Reply With Quote
 
     
 
 
Old Mar 23, 2005, 09:32 PM   #6  
New Member
DANZ is offline
 
Join Date: Mar 2005
Posts: 1
DANZ See this member's comment history on his/her Profile page.
is there anyway to recalculate the total if a colour is changed? as it seems excel doesnt class a fill colour as a value.
  Reply With Quote
 
     
 
 
Old Mar 24, 2005, 07:07 AM   #7  
New Member
leif5233 is offline
 
Join Date: Nov 2004
Posts: 2
leif5233 See this member's comment history on his/her Profile page.
Re-calcs

There are cleaner (and more complicated) ways to auto-calc, but the simplest I can offer is this. Add:

Application.Volatile (True)

above the "Dim" statements in the code I listed before.

Then, just hit "F9" everytime you want the cells to recalc.

If you want it to recalc automatically, you'll have to create a class module and override one of the application object's standard events. Here's a link for you to check out if interested:
html Code:
http://www.microsoft.com/exceldev/articles/xlevnts.htm

Leif
  Reply With Quote
 
     
 
 
Old Apr 26, 2006, 07:10 AM   #8  
New Member
h_arveys is offline
 
Join Date: Apr 2006
Posts: 1
h_arveys See this member's comment history on his/her Profile page.
I have the same issue. I want to count the number of entries that are "RED". I know there is an excel formula that does it because I have done it before. Unfortunately I have deleted the work book that had the formula so I am searching for it again.

example: =countif(a1:a15, fontcolor="red") or something like that...I have tried all the variations I can think of so I must not have it right.

Any ideas?
  Reply With Quote
 
     

Bookmarks


Thread Tools
Display Modes

 
Similar Sponsors

Similar Threads
Question Asker Forum Answers Last Post
Does Sincerity Count? Starman Christianity 19 May 4, 2007 10:57 PM
Count in the Report sukkarfarid Visual Basic 5 Sep 10, 2006 04:01 AM
How to remove a character using Excel function dogdog3 Spreadsheets 3 Aug 5, 2006 06:01 AM
Count my web page Geo2006 Internet & the Web 3 Jan 23, 2006 03:31 AM




Copyright ©2003 - 2007, Ask Me Help Desk.
All times are GMT -8. The time now is 12:03 PM.