+ Reply to Thread
Results 1 to 11 of 11

combine countif and mod functions

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    MS 2007
    Posts
    45

    combine countif and mod functions

    I want to count the number of entries in a column of numbers that are not evenly divisible by 0.25. I'm unsuccessfully trying:

    =COUNTIF(MOD(H2:H26,0.25,<>0))

    Any pointers?

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: combine countif and mod functions

    Try it this way:

    =SUMPRODUCT(--(MOD(4*H2:H26,4)=0))

    I've multiplied the array by 4 and used 4 as the divisor, as dividing by fractions may give rounding errors.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    07-24-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    MS 2007
    Posts
    45

    Re: combine countif and mod functions

    Thanks for quick reply. I'm still getting notice: "The formula you typed contains an error."

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: combine countif and mod functions

    Don't type the formula, then - instead, highlight it on the post above, then CTRL-C, then click onto the Excel window, select the cell that is to contain the formula, click into the Formula bar and highlight the contents (if any), then CTRL-V and press Enter.

    Hope this helps.

    Pete

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: combine countif and mod functions

    Quote Originally Posted by Pete_UK View Post
    =SUMPRODUCT(--(MOD(4*H2:H26,4)=0))
    Wouldn't that only count integers?

    I think it should be:

    =SUMPRODUCT(--(MOD(4*H2:H26,1)=0))

    or to avoid counting blank cells you might want this version

    =SUMPRODUCT((H2:H26<>"")*(MOD(4*H2:H26,1)=0))
    Audere est facere

  6. #6
    Registered User
    Join Date
    07-24-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    MS 2007
    Posts
    45

    Re: combine countif and mod functions

    None of those is working. I probably haven't made my objective clear. Column H has a bunch of numbers in it. I want to know how many of those numbers are not evenly divisible by 0.25. For example, if Column H has the following numbers in it:
    2.25
    3.75
    4.00
    3.9
    3.5
    3.3
    I want the answer to be 2 because there are 2 numbers (3.9 and 3.3) that are not evenly divisible by 0.25. Anyone care to try again?

  7. #7
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: combine countif and mod functions

    My modification to Pete's formula is counting the values which are divisible by 0.25......but if you want the opposite just change the = to <>, i.e.

    =SUMPRODUCT(--(MOD(4*H2:H26,1)<>0))

    I get 2 with that formula and your data

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: combine countif and mod functions

    Try this:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  9. #9
    Registered User
    Join Date
    07-24-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    MS 2007
    Posts
    45

    Re: combine countif and mod functions

    Yay! Thank you! This works like a charm!

  10. #10
    Registered User
    Join Date
    07-24-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    MS 2007
    Posts
    45

    Re: combine countif and mod functions

    I should make it clear that Daddylonglegs' formula:

    =SUMPRODUCT(--(MOD(4*H2:H26,1)<>0))

    is what worked for me. Thanks again!!!

  11. #11
    Registered User
    Join Date
    07-24-2013
    Location
    Salt Lake City, Utah
    MS-Off Ver
    MS 2007
    Posts
    45

    Re: combine countif and mod functions

    OK, last note. I just tried newdoverman's solution (below) and it worked, too! Thank you both!

    =SUMPRODUCT(--(MOD(A1:A6,0.25)>0))

+ 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] How do I combine countif and sumproduct functions?
    By wwwth2 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-22-2014, 04:29 PM
  2. [SOLVED] Best way to combine Countif and OR functions.
    By Matthew_Ky in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-30-2014, 10:57 AM
  3. How do I combine the COUNTIF and the OR functions into a single command
    By gwilymh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-19-2012, 04:35 PM
  4. Combine sum, offset, and countif functions
    By cbarr1987 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-24-2012, 11:32 AM
  5. [SOLVED] How do I combine COUNTIF and AND functions in Excel
    By J Roney in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-15-2005, 06:45 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