+ Reply to Thread
Results 1 to 10 of 10

Countif, value and background color

  1. #1
    Registered User
    Join Date
    07-13-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    6

    Countif, value and background color

    Is it possible to make a macro that counts the number of cells with a specific value and background color? Ideally you should be able to fill in criteria in a formula on the sheet (color criteria as color index).

  2. #2
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Countif, value and background color

    Yes. The following sub counts the number of cells in range A1:A20 for values matching the value in cell B1 and the color of cell B2.




    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    07-13-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Countif, value and background color

    Should I write =ColorFunction in the cell where I want the result, I get #NAME?.

  4. #4
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Countif, value and background color

    See the attached file. Click the Count button (which runs the sub called CountCells). It counts the number of cells in the range A1:A20 which match the value of cell B1 and the colour of cell B2.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    07-13-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Countif, value and background color

    You have not attached any file.

  6. #6
    Registered User
    Join Date
    07-13-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Countif, value and background color

    Thank you very much, it worked.
    Last edited by jope1993; 08-03-2012 at 12:35 PM.

  7. #7
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Countif, value and background color

    @ jope1993

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

  8. #8
    Registered User
    Join Date
    07-13-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Countif, value and background color

    @ mojo249

    Excuse me, it was me that was not clear, but I need a macro that only counts cells that both the value and the reverse primer corresponds to the specified value and the reverse primer.

    For example, if the specified value is 3 and the reverse primer is blue, then you should only count cells that have both the 3 and the background color blue. It should not count on a cell such as reverse primer would be green but still the value is 3.

    Hope you can understand what I mean.

  9. #9
    Forum Contributor
    Join Date
    05-09-2009
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    315

    Re: Countif, value and background color

    Jope

    The best way of learning is having a go. I've shown you how to count based on value and colour. Try modifying it to suit your needs.

    If you get stuck post back.

    Dion

  10. #10
    Registered User
    Join Date
    07-13-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Countif, value and background color

    Sorry that I have not responded.

    I know that the best way to learn is by trying yourself. And this I have done, but failed and the reason I wrote on the forum.

+ 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