+ Reply to Thread
Results 1 to 17 of 17

How to count cells by color?

  1. #1
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    How to count cells by color?

    Hi,

    how to count how many cells are in color yellow in a huge database that looks as in the attached file?

    TRACK_BY_COLOR.JPG

    Many thanks.
    Gabriele

  2. #2
    Forum Contributor
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    227

    Re: How to count cells by color?

    Quote Originally Posted by gabrielemucho View Post
    Hi,

    how to count how many cells are in color yellow in a huge database that looks as in the attached file?

    Many thanks.
    Gabriele
    Hi,

    you can use this code for counting the coloured cells, just update the Range as per your sheet.


    Please Login or Register  to view this content.
    If I've been of help, plz add reputation.

  3. #3
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How to count cells by color?

    Hi,

    Thank you, it works nicely in the worksheet with one color.

    what code would work if the database contained more colors and I needed to count only those cells that are color yellow as in the following example:

    COLORED DATA.JPG

    Thank you,
    Gabriele

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to count cells by color?

    This UDF can do this.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How to count cells by color?

    Hi Fotis,

    when I try to run the macro you suggested, I get the dialog box saying 'Argument not optional'....

    Thanks,
    Gabriele

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to count cells by color?

    Gabriele

    As UDF works fine in workbook that i uploaded, i can't imagine what is this that you don't do correctly.

    Did you add the code that i suggested to a normal module?

    Did you used the columns reference in the UDF correctly?

    If so, then i think that you have to upload a small sample workbook WITH my code, to see what happens.

  7. #7
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How to count cells by color?

    Fotis,

    what do you mean by 'normal module'?

    Gabriele

  8. #8
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to count cells by color?

    Open the Visual Basic Editor which is built into Microsoft Excel by going to Tools->Macro->Visual Basic Editor (or pressing Alt+F11). Add the code.

    Look here how to do this.

  9. #9
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How to count cells by color?

    Thank you for the link. I've got it now right, almost right... That is, for some reason the macro gets the right count for cells in yellow and orange (18 and 14 respectively), but it yields the wrong count for the pink color - it gives 14, when the correct count should be 27... Any idea what went wrong?

    Thanks,
    Gabriele

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to count cells by color?

    I can think that there aren't ALL the "pink cells" the same pink.. Or perhaps you get the pink colour in SOME of the cells using Conditional Formattng..OR.......really i don't know without to see your data.

  11. #11
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How to count cells by color?

    Hm, it is the same pink (or whatever it's called, I added color by hand in that sample). And the sample data is attached as jpg in my questioned posted earlier today, or do you need it in excel attachement to figure out the problem?

    G

  12. #12
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to count cells by color?

    An Excel attachement-a WORKBOOK-will be good.

  13. #13
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How to count cells by color?

    here it is
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Re: How to count cells by color?

    You haven't added the code to VBA.

    Press ALT+F10 in Fotis's attachment and add the coding to your workbook

  15. #15
    Forum Contributor
    Join Date
    09-18-2014
    Location
    England
    MS-Off Ver
    2003/2010/365
    Posts
    119

    Re: How to count cells by color?

    Apologises, ALT+F11

  16. #16
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: How to count cells by color?

    Ok. You uploaded a sheet without the code BUT this wasn't the problem. The problem was(as i previously mentioned) that were not ALL the cells filled with the same(pink?!) color.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    11-11-2012
    Location
    England
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: How to count cells by color?

    Hi Fotis,

    sorry for this, that ugly pink looked all the same to me. It works indeed.
    Thank you for solution!
    Gabriele

+ 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. HOW DO I COUNT CELLS OF A CERTAIN COLOR ONLY?
    By JE McGimpsey in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 11:05 AM
  3. HOW DO I COUNT CELLS OF A CERTAIN COLOR ONLY?
    By Martin C in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  4. HOW DO I COUNT CELLS OF A CERTAIN COLOR ONLY?
    By Martin C in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM
  5. how to formate cells to count cells with a fill color?
    By Moore in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-15-2005, 02:05 PM

Tags for this Thread

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