+ Reply to Thread
Results 1 to 2 of 2

Counting Cell Colours

  1. #1
    Registered User
    Join Date
    03-08-2011
    Location
    Norwich England
    MS-Off Ver
    Excel 2007
    Posts
    5

    Counting Cell Colours

    Hi hope someone can help, I have downloaded a VBA code seen below. it works fine but when a cell has no colour I need the cell count to read blank instead of 0. Do I have to have 3 different rules, 1: to count cells if they are yellow and input the number of coloured cells, 2: to count cells that have a colour pink to input a zero value and 3: to count none coloured cells to input a blank value. I am very new to this so bear with me, thanks in advance

    VBA Project.jpg

    Function CountCcolor(range_data As Range, criteria As Range) As Long
    Application.Volatile True
    Dim datax As Range
    Dim xcolor As Long
    xcolor = criteria.Interior.ColorIndex
    For Each datax In range_data
    If datax.Interior.ColorIndex = xcolor Then
    CountCcolor = CountCcolor + 1

    End If
    Next datax

    End Function
    Last edited by Willows; 06-28-2014 at 09:38 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Counting Cell Colours

    Hi,

    I presume by 'when a cell has no colour' that you mean the criteria cell.

    Try instead

    Please Login or Register  to view this content.
    Incidentally please note the forum rules about embedding code in code tags so that it formats. I'll let it pass this time but please note.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ 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] Countif with counting colours
    By Nikeyg in forum Excel General
    Replies: 8
    Last Post: 12-20-2013, 04:39 AM
  2. Counting Colours
    By matthew.lawson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-06-2013, 07:03 AM
  3. Counting numbers and colours within a cell
    By ibenam in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 02-06-2013, 11:30 AM
  4. Counting colours and names
    By knickolyed in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-16-2008, 09:11 AM
  5. Excel 2003 font colours and cell colours
    By bretta in forum Excel General
    Replies: 1
    Last Post: 04-16-2005, 11: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