Excel Countif Modulus on list of values

Hi Experts

I've got the following sample data in a single column in my XLS:


I need a formula to calculate the number of values in this data range that have a modulus of 0.35 to 0.50 (both values inclusive) - the correct answer is: 2

What is the formula I should use?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieVBA ExpertCommented:

=SUMPRODUCT(--(MOD(A1:A12,1)>=0.35),--( MOD(A1:A12,1)<=0.5))
wesmanbigmig13Author Commented:
Thanks Norie - this looks promising, however I just tried the following on this set of values and it should return a result of 2, but instead it returns a result of 1...

=SUMPRODUCT(--(MOD(C59:C70,1)>=0.18), --(MOD(C59:C70,1)<=0.21))

Seems like it isn't including one of the values 0.18 or 0.21 ...?
wesmanbigmig13Author Commented:
Testing further, it seems like it is the less than or equal to value (<=0.21) which it isn't including correctly, because if I change the formula to the following:

=SUMPRODUCT(--(MOD(C59:C70,1)>=0.18), --(MOD(C59:C70,1)<=0.22))

it returns the correct result of 2. Why does the <= function not work correctly? It seems to be ignoring the = to part of only working on the < part...
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

NorieVBA ExpertCommented:
Can you show the other set of data you tried it on?

Perhaps upload a sample workbook?
wesmanbigmig13Author Commented:
Hi Norie - please see attached file. The result for the formula should be 3, but Excel shows 2
NorieVBA ExpertCommented:
I think this is a caused by the way Excel, well computers, store decimalnumbers, see here.

If we use the ROUND function to round to 2 decimal places the correct result is returned.

=SUMPRODUCT(--(ROUND(MOD(A1:A12,1),2)>=0.21), --(ROUND(MOD(A1:A12,1),2)<=0.34))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
wesmanbigmig13Author Commented:
Perfect, thanks Norie. Worked a charm!


It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.