+ Reply to Thread
Results 1 to 6 of 6

Countif/s searching 2 criteria and 2 range and only counting if both are correct

  1. #1
    Registered User
    Join Date
    11-15-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    10

    Countif/s searching 2 criteria and 2 range and only counting if both are correct

    Hi All,

    I seem to be having some trouble trying to have countif/s functions that search 2 different ranges for 2 different criteria and displaying the count on a sheet only if both criteria match the search.

    These are two examples i have tried using but do not work as it is only searching one range as a range, the other range is being seen as an argument.

    Worksheets("Data Summary").Range("C65").Value = Application.WorksheetFunction.CountIf((Range("$U1:$U1048576"), "joeb"),(Range("$Z1:$Z1048576"), "1"))

    Worksheets("Data Summary").Range("C65").Value = Application.WorksheetFunction.CountIfs((Range("$U1:$U1048576"),"joeb"),(Range("$Z1:$Z1048576"), "1"))

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Countif/s searching 2 criteria and 2 range and only counting if both are correct

    Try it like this...

    Please Login or Register  to view this content.
    Please note that since you are not qualifying the ranges used in CountIfs function with the sheet, it will count the values from the ActiveSheet only and write the output on Data Summary Sheet.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Registered User
    Join Date
    11-15-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    10

    Re: Countif/s searching 2 criteria and 2 range and only counting if both are correct

    i will try that code in a minute.

    regarding the bit you mentioned regarding the ActiveSheet only, does this still matter if the code is on the sheet itself (not in a module) and that it is called at the end of a module?

  4. #4
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Countif/s searching 2 criteria and 2 range and only counting if both are correct

    If the code in on Sheet Module, the range will refer to that sheet itself.

  5. #5
    Registered User
    Join Date
    11-15-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    10

    Re: Countif/s searching 2 criteria and 2 range and only counting if both are correct

    Ok that is what I thought, its all working fine now

  6. #6
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,648

    Re: Countif/s searching 2 criteria and 2 range and only counting if both are correct

    Glad to know that it is working as desired. Thanks for the feedback.

    You may also say thanks to those who have put their time and efforts to help you in this forum by clicking the Add Reputation link under their posts, another way to say thanks.

+ 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. correct syntax for countif conditional delete in range...
    By morbenforsen in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 01-06-2016, 08:11 PM
  2. Counting with criteria (more than countif?)
    By C'mern in forum Excel General
    Replies: 5
    Last Post: 11-17-2011, 12:22 PM
  3. [SOLVED] COUNTIF or SUMPRODUCT counting multiple criteria
    By Kim in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 03:05 AM
  4. COUNTIF or SUMPRODUCT counting multiple criteria
    By Kim in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 01:05 AM
  5. [SOLVED] COUNTIF or SUMPRODUCT counting multiple criteria
    By Kim in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 12:05 AM
  6. [SOLVED] COUNTIF or SUMPRODUCT counting multiple criteria
    By Kim in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-05-2005, 11:05 PM
  7. counting cells (COUNTIF) based on two or more criteria
    By Tricia S. in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-17-2005, 11:06 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