Ask Experts Questions for FREE Help !
Ask
    eddiegeorge's Avatar
    eddiegeorge Posts: 1, Reputation: 1
    New Member
     
    #1

    Oct 25, 2006, 04:14 AM
    Excel Count Function
    In November 2004 Leif 5233 wrote the following regarding counting cells highlighted in a certain colour:

    ------------------
    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
    -----------------

    This works great unless the cell is highlighted as a result of conditional formating. Is there any way of counting cells that are highlighted due to conditional formating?
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Oct 25, 2006, 06:21 AM
    Instead of checking the format of the cell, check the condition. You can modify the line:

    If Cell.Interior.ColorIndex = intColor Then

    To test for the condition rather than the colorindex.
    ahmed kamal's Avatar
    ahmed kamal Posts: 2, Reputation: 1
    New Member
     
    #3

    Oct 26, 2006, 03:42 AM
    . I have 2 sets of data (x and y), I want to count (less than and more than) above each data (for x and y) and also (less than and more than) below the data itself (for x and y). This is for each data x and y. What is the proper function I can use. Many thanks
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Oct 26, 2006, 06:00 AM
    Not sure I follow. If you want to compare X and Y and count how many times x > y and y > x, then I would add a column with an expression like:

    =IF(A2>B2,"Over","Under")

    This assumes that x is in the A column and Y in the B Column. The result will put the text Over and Under for each row. You can then use CountIf to count each.
    miss-java's Avatar
    miss-java Posts: 4, Reputation: 1
    New Member
     
    #5

    Mar 22, 2007, 10:33 AM
    https://www.askmehelpdesk.com/other-...tml#post335426
    (any one could help me with this.. I would be thankfull)

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Excel count function [ 12 Answers ]

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.

Does Sincerity Count? [ 20 Answers ]

I have often heard some Christians say that sincerity doesn't count if it is based on innacurate knowledge and that such ignorance can lead to ultimate destruction at the hands of God. I disagree with this concept. Do you? They cite the following scripture to support their conclusion. Romans...

Another Count Question [ 1 Answers ]

I have a Spread sheet which links to my Database. This sheet querys the database and puts everything in a what we call a "TAM" number order. (example D1158 , D1159 , D1125). All of these numbers are shown in Column A. Is there a way I can set a cell to count the number of D1158's there are? I have...

Count question [ 2 Answers ]

I have a spreadsheet that calculates the number of minutes late a truck is in departing compared to a target time. There are a number of trucks listed, each with a different target time. In column “D” each truck has a destination code of ether “Prov”, “HD” of “SC”. I want to be able to count the...

How to remove a character using Excel function [ 3 Answers ]

Could anyone know if there is any Excel function that I can use to remove a certain character from a text string, e.g. 1). Remove space from "acurve is what" 2). Remove "-" from "acurve-is-what" 3). Remove "'" from "acurve'is" And so on. Thanks a lot!


View more questions Search