+ Reply to Thread
Results 1 to 8 of 8

Help: Countif Specific Value & Formatting

  1. #1
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Help: Countif Specific Value & Formatting

    Hello, I have been searching the web all morning trying to find a solution with no luck. I'm assuming VBA will be needed to pull this off.

    Basically I am trying write a formula that checks one cell on my sheet for a specific value, and counts the amount of times the value appears in column G. The problem is I have the same values in that column but have different fill colors, that I would like to exclude from the count.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Help: Countif Specific Value & Formatting

    If you need to check colours then you will need VBA.

    It would help if you could post a small sample fill explaining your requirement,

  3. #3
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Help: Countif Specific Value & Formatting

    Well...

    at first I started with a simple COUNTIF formula, which works if I am trying to find the exact value.

    =COUNTIF(A:A,A2)


    Then I found a way to search by color using VBA.

    FORMULA:
    =countccolor(G6:G1000,B8)

    VBA:
    Function CountCcolor(range_data As Range, criteria As Range) As Long
    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


    The problem is that neither of these can count based on the value and color fill of the referenced cell.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Help: Countif Specific Value & Formatting

    The Attached code will count a cell with given color and containing text


    Please Login or Register  to view this content.
    =countCcolorX(A1:A8,C1,"G")

    counts cells containing "G" in cells with color of C1

  5. #5
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Help: Countif Specific Value & Formatting

    Thank you, this works!

    I have one question, the count does auto update if I add/remove another instance of the value to the range, but it doesn't update the count if I change the color of one of the cells in the range manually. I have to click in the cell with the formula and press enter to get it to update the count. Any ideas on how to make the formula auto update?

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Help: Countif Specific Value & Formatting

    I am not aware of any mechanism that will do this - it will only recalculate when you press enter.

  7. #7
    Registered User
    Join Date
    11-09-2012
    Location
    seattle
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: Help: Countif Specific Value & Formatting

    Thank you so much!

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,152

    Re: Help: Countif Specific Value & Formatting

    Could mark thread as solved ("Thread Tools" at top of first post). Thank you.

+ 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 on a Specific Column Header versus a specific Column
    By usc1382 in forum Excel General
    Replies: 7
    Last Post: 07-14-2020, 02:41 AM
  2. [SOLVED] countif - specific criteria
    By jambo2013 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-15-2015, 04:09 AM
  3. Replies: 1
    Last Post: 08-28-2013, 09:07 AM
  4. Copy specific data to another workbook following specific formatting
    By sophie.loor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-04-2012, 12:04 PM
  5. [SOLVED] COUNTIF Formulas up until a specific day
    By howe7032 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-05-2012, 08:57 PM
  6. [SOLVED] Help please! Countif for specific cells in a row
    By RikkiBernaud in forum Excel General
    Replies: 11
    Last Post: 07-05-2012, 09:23 AM
  7. Using COUNTIF on specific cells
    By harshaputhraya in forum Excel General
    Replies: 4
    Last Post: 05-08-2006, 12:27 AM

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