+ Reply to Thread
Results 1 to 9 of 9

VBA - count by multiple criteria and font colour

  1. #1
    Registered User
    Join Date
    12-11-2020
    Location
    Ireland
    MS-Off Ver
    MS Office Professional Plus 13
    Posts
    5

    VBA - count by multiple criteria and font colour

    Hello

    I am trying to write a function that will count by multiple criteria and font colour.
    I basically want to be able to determine the number of human errors per person whilst omitting names in red.
    I have a column of names (those with failing result) and a column of causes.
    I realise I can use the countifs function for the names and human error but I can't omit those in red.
    I can write a function that will count how many times a name appears in a range, omitting the red ones. How can I merge these?
    I have also written a function that will count human errors in a given range. I just can't seem to make it count how many human errors per person for a given range!
    Out of interest I'd like to work out the VBA code for this, as well as actually finding a solution.

  2. #2
    Registered User
    Join Date
    12-11-2020
    Location
    Ireland
    MS-Off Ver
    MS Office Professional Plus 13
    Posts
    5

    Re: VBA - count by multiple criteria and font colour

    Example attached
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-20-2020
    Location
    Québec, Canada
    MS-Off Ver
    MS Office 2013
    Posts
    19

    Re: VBA - count by multiple criteria and font colour

    When you enter the function in the cell, which cells should be selected in the range and what should be in criteria1?

  4. #4
    Registered User
    Join Date
    12-11-2020
    Location
    Ireland
    MS-Off Ver
    MS Office Professional Plus 13
    Posts
    5

    Re: VBA - count by multiple criteria and font colour

    So I'm selecting the names for a given week and the criteria is the first name on the second sheet. And then I iterate through changing criteria1 to each name.
    E.g Week 1: I select the names for that week (B2:B14) and then the Criteria1 iterates from Sheet2 A2:15. Does that make sense?

  5. #5
    Registered User
    Join Date
    11-20-2020
    Location
    Québec, Canada
    MS-Off Ver
    MS Office 2013
    Posts
    19

    Re: VBA - count by multiple criteria and font colour

    Try this out. Note that this doesn't include your range 2. Maybe with this you might be able to merge your 2 functions together.
    Attached Files Attached Files
    Last edited by nightseeker; 12-11-2020 at 05:33 AM.

  6. #6
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA - count by multiple criteria and font colour

    Here's how I read your request.
    UDF
    Formula in Sheet2!B2
    =CountName(Sheet1!$A$2:$C$40,B$1,$A2,3)
    then copy right + down

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

  7. #7
    Registered User
    Join Date
    12-11-2020
    Location
    Ireland
    MS-Off Ver
    MS Office Professional Plus 13
    Posts
    5

    Re: VBA - count by multiple criteria and font colour

    It's the merging I'm struggling with!

  8. #8
    Registered User
    Join Date
    12-11-2020
    Location
    Ireland
    MS-Off Ver
    MS Office Professional Plus 13
    Posts
    5

    Re: VBA - count by multiple criteria and font colour

    Ah yes that works! Do you think you could explain it to me a bit?

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: VBA - count by multiple criteria and font colour

    1)
    Please Login or Register  to view this content.
    This enable to use F9 to recalculate since Change of Font/Interior color cell format will not trigger to recalculate.
    2)

    Please Login or Register  to view this content.
    Assuming the referenced cell contains the value like "Week #" or just "x #" and it reads "#" part
    3)
    Please Login or Register  to view this content.
    Extract the row reference within rng that is/are 1st column matches "#" part, AND 2nd column matches to Name AND 3rd column is not empty.
    4)
    Please Login or Register  to view this content.
    Loop though the result and it adds to CountName when font colorindex of 2nd column of that row is not 3.

    Do a step debug for yourself first.

+ 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] Returning a count of how many letters in a string are a certain font colour
    By scott0808 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2020, 08:05 AM
  2. [SOLVED] How to count conditionally formatted font (red) cells and cell colour
    By Nampara in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-01-2018, 04:48 PM
  3. [SOLVED] Count Based on Text and Font colour
    By SamFitz in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-02-2016, 12:39 PM
  4. [SOLVED] Count how many red colour font text or numeric in a column
    By PRADEEPB270 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-12-2013, 02:56 AM
  5. Multiple Fill Color & Font Colour icons on menu bar
    By robertguy in forum Excel General
    Replies: 3
    Last Post: 02-05-2008, 10:46 AM
  6. Count by value AND by font colour
    By Blondegirl in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-22-2006, 07:36 AM
  7. Criteria - Automatic Change Font or Fill Colour
    By stevembe in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-04-2005, 12:05 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