+ Reply to Thread
Results 1 to 4 of 4

Count Cells in a range with a Certain Color

  1. #1
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Count Cells in a range with a Certain Color

    I want to be able to count the number of cells in a Range where the color of the cells is a certain Color. It would be easiest if eth Colour was determined by the Fill color of the Cell in which the Formula sat. The Colour may have been via a manual Fill, Conditional Formatting or from a Style.

    I think this would be a VBA solution - so If anyone has something to do the job that would be great.

    Thank You

    Allister
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Count Cells in a range with a Certain Color

    This gets a bit messy because the usual way to count colours (interior.color) does not work for conditional formatting, and while displayformat works in macros for some odd reason it doesn't in user-defined functions. this workaround uses evaluate and seems to work
    The user-defined formula ColCount counts all the cells in the selected range that have the same interior colour as the active cell. So entering
    =ColCount(G1:G20)
    in cell M5 of your sheet returns the value 9

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-10-2020
    Location
    New Zealand
    MS-Off Ver
    365 personal
    Posts
    302

    Re: Count Cells in a range with a Certain Color

    Works nicely Nicky. To get it to update I needed to do a f2 on the cell with the formula in it. Is this what you expected. How do I get it to update automatically?
    Allister

  4. #4
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Count Cells in a range with a Certain Color

    Hi Allister
    sorry, I overlooked you post
    Updating user-defined functions can be a bit tricky. This site suggests some workarounds:
    HTML Code: 

+ 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. [SOLVED] change fill color of a range of cells based on color of a cell?
    By DarMelNel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-20-2014, 04:48 PM
  2. Count cells in a range that have same bacgoround color
    By tavaritz in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-27-2013, 09:35 AM
  3. Replies: 12
    Last Post: 09-18-2012, 03:13 PM
  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. [SOLVED] 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
  6. [SOLVED] Formula to count the cells in a range that have a fill color.
    By Slainteva in forum Excel General
    Replies: 2
    Last Post: 01-19-2005, 05:06 PM
  7. Replies: 2
    Last Post: 01-19-2005, 04:06 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