+ Reply to Thread
Results 1 to 22 of 22

Count the number of cells with a specific colour

  1. #1
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Count the number of cells with a specific colour

    Hello all,

    How can we count the number of cells with a specific colour.
    For example, how many cells are yellow, red, green, orange etc...

    In my worksheet the column with a coloured cells is column B.

    Thank you!

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Count the number of cells with a specific colour

    Do you have a sample? Where do you want the counts to appear?
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    Hello Arlu

    Here is the sample workbook. I want to count the different colours in Column B (how many yellows, red etc..)[ATTACH]219920. Lets say i want the count to appear in C2.

    Thank you

    TestColor.xlsx

  4. #4
    Registered User
    Join Date
    03-08-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Count the number of cells with a specific colour


  5. #5
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    Not working with me. Maybe I am copying wrongly...

  6. #6
    Registered User
    Join Date
    03-08-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Count the number of cells with a specific colour

    take a new excel and try again, the file which you attached has some issues

    lemme know

  7. #7
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    I tried it and after copying the function I am receiving this error message in the cell: ''#NAME?''

  8. #8
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    Arlu, any ideas?

  9. #9
    Registered User
    Join Date
    03-08-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Count the number of cells with a specific colour

    Look at this workbook whic i tried
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    OK. But If I want to expand it i.e instead A1:A8 i write A1:A16, I get the same error message (#Name!)

  11. #11
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    And I referech the formula (ctrl+alt+F9) i get the same error

  12. #12
    Registered User
    Join Date
    03-08-2013
    Location
    New York
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Count the number of cells with a specific colour

    ahhh, seems when you close the excel, the code dissappears which result the error

    so make sure, the code is in there when you modify the cells. try to edit the formula, its working that way.

    am not sure why the code is lost...lemme look in to it

  13. #13
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    did you figure out?

  14. #14
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Count the number of cells with a specific colour

    This seems to work when I manually add the interior colors, but it didn't work for some reason on your sample.

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    Hello John,

    Can you try it on a simple example and post it?

    Thank you very much!

  16. #16
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    I tried...I dont think it worked. Btw i there a way the number appear in a cell instead of msg box?

  17. #17
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Count the number of cells with a specific colour

    Hi Naja
    It would be better to use conditional formatting criteria than the colour of the conditional formatting, see the attachment
    Attached Files Attached Files

  18. #18
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Count the number of cells with a specific colour

    Quote Originally Posted by Naja View Post
    Hello John,

    Can you try it on a simple example and post it?

    Thank you very much!
    It worked on this attachment.

    Wrong attachment
    Attached Files Attached Files
    Last edited by JOHN H. DAVIS; 03-12-2013 at 10:41 AM.

  19. #19
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Count the number of cells with a specific colour

    Here it is:

    Attachment 220210

  20. #20
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    the last attachment is not working (says it is not valid)
    Plus is there a way to display the results in a cell instead of msg box.

    Thank you John!!

  21. #21
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Count the number of cells with a specific colour

    Yes. But I need first to understand why when you test the code it doesn't work. It worked on my test.

  22. #22
    Forum Contributor
    Join Date
    11-05-2012
    Location
    Montreal
    MS-Off Ver
    Excel 2007
    Posts
    107

    Re: Count the number of cells with a specific colour

    I mean the attachment ''Attachment 220210 '' is not opening. There is an error. Maybe if you post it again.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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