+ Reply to Thread
Results 1 to 4 of 4

countif with more than 2 searches

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    countif with more than 2 searches

    This works. It looks for two values in different colums.



    Range("D2").Value = Application.WorksheetFunction.CountIfs(Range("A7:A1206"), "WC", Range("AB7:AB1206"), "Y",)
    which is the same as
    =COUNTIFS(A7:A1260,"WC", AB7:AB1260,"Y")
    in cell D2

    but when I try looking for 4 values it comes back as unable to get the CountIfs property of the worksheetfunction class

    Range("D2").Value = Application.WorksheetFunction.CountIfs(Range("A7:A1206"), "WC", Range("AB7:AB1206"), "Y", Range("F7:F1260"), "3", Range("G7:G1260"), Range("G7"))
    this one is the same as

    =COUNTIFS(A7:A1260,"WC", AB7:AB1260,"Y", AB7:AB1206,"Y", F7:F1260,"3",G7:G1260,G7)
    in cell D2

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: countif with more than 2 searches

    There's a typo in your code.

    You begin with ranges of 1206 and then you switch to ranges of 1260.
    Make Mom proud: Add to my reputation if I helped out!

    Make the Moderators happy: Mark the Thread as Solved if your question was answered!

  3. #3
    Forum Contributor
    Join Date
    08-07-2013
    Location
    mo
    MS-Off Ver
    Excel 2010
    Posts
    453

    Re: countif with more than 2 searches

    oHHHHHHHHHHHHHHHHHHHHHHHHHHHH MYYYYYYYYYYYYYYYYYY...... You are Correct............... I have been trying to figure this out for 2 hours. Good eye.......

  4. #4
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: countif with more than 2 searches

    Pro tip: use line breaks in your code to make troubleshooting easier.

    x = Application.WorksheetFunction.CountIfs(Range("A7:A1206"), "WC", _
                                               Range("AB7:AB1206"), "Y", _
                                               Range("F7:F1260"), "3", _
                                               Range("G7:G1260"), Range("G7"))
    Much easier to read!

    Coincidentally, also can be done in spreadsheet land with liberal use of Alt+Enter

    =SUMPRODUCT((F2:F6="BOB")*
    	    (G2:G6=2)*
    	    (H2:H6="Yellow")*
    	    (J2:J6="Batman"))

+ 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] Other was to do more then 6 searches in one formula
    By Shannon561 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-02-2014, 07:43 PM
  2. Countif formula for multiple searches and answers in one cell
    By RTrac in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-11-2012, 05:00 PM
  3. [SOLVED] Recordset Searches
    By James McDowell in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-11-2006, 06:25 PM
  4. Getting valid web searches and avoiding sites that contaminate web searches
    By David McRitchie in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-12-2006, 10:10 PM
  5. Searches
    By peterrump in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-23-2005, 04:06 PM

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