+ Reply to Thread
Results 1 to 8 of 8

Excel - count cells based on color

Hybrid View

  1. #1
    Registered User
    Join Date
    03-19-2014
    Location
    South Carolina
    MS-Off Ver
    Excel 2010
    Posts
    8

    Excel - count cells based on color

    Hi, this is an easy one, but I cannot find a matching thread for the answer.

    Column cells conditional formatted to color fill based on content of cell, now I want to count the # of cells that are orange or green, etc. I have a key listing the colors where I want to display the totals.

    Your assistance is appreciated.

    Thanks,
    R

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,720

    Re: Excel - count cells based on color

    Since you have conditionally formatted the colors, why not use the same logic to count the cells employing either the Countif or Countifs functions within Excel.

    Alan
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    03-19-2014
    Location
    South Carolina
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Excel - count cells based on color

    honestly, I don't know how to do that - how do I idenitfy each color in my column?

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Excel - count cells based on color

    you dont need to say its column a
    and orange cells are coloured by cf using the rule >1 then use countif
    eg countif(a1:A100,">1")
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Excel - count cells based on color

    Here is a vb UDF solution for you

    1. Copy code below
    2. Press Alt and F11 on your keyboard to open VB Editor
    3. Click on Insert and select Module
    4. Paste code into Module and close VB Editor.

    Use formula

    example:
    =GetColor(A2) and drag formula down. Formula will return numeric value for each color which you can count with COUNTIF function.

    Function GetColor(Mycell As Range)
    GetColor = Mycell.Interior.ColorIndex
    End Function
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Registered User
    Join Date
    03-19-2014
    Location
    South Carolina
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Excel - count cells based on color

    I think the issue I am having is because the cells I am trying to count are conditionally formatted to a specific color based on cell value. Any advice?

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Excel - count cells based on color

    @Rbordonaro

    Did you try the solution I offered?

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,720

    Re: Excel - count cells based on color

    Use the same logic that you used to conditionally format in your countif function. Martin has given you an example how to do this. What is the logic to color the cells.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 05-02-2012, 09:08 AM
  2. [SOLVED] Count cells based on a fill color
    By Mike K. in forum Excel General
    Replies: 2
    Last Post: 06-13-2011, 03:04 PM
  3. Count Cells Based On A Background Color
    By NSTurk725 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-27-2010, 11:29 AM
  4. Count Cells in a Row based on color and date range
    By indnracn2 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-14-2009, 11:12 PM
  5. Is there a way to count cells in a range based on fill color?
    By eehinmd in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-16-2006, 01:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1