?
Solved

using the countif function

Posted on 1999-01-11
8
Medium Priority
?
288 Views
Last Modified: 2006-11-17
when using the countif formula how do I set 2 criteria
eg countif(A1:A800,">B1","<B2"). The data in cells B1 & B2 are dates.





[Cancel Editing]
[How To Use Experts Exchange]
[Home]

Copyrights © 1996-1998 Experts Exchange, Inc. - Patent Pending
0
Comment
Question by:antrat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 9

Author Comment

by:antrat
ID: 1615543
Edited text of question
0
 
LVL 9

Author Comment

by:antrat
ID: 1615544
Edited text of question
0
 
LVL 5

Expert Comment

by:jboddy
ID: 1615545
You don't! It only alows for one criteria.
You will have to work around it.
Try using something like this (note the use of x to represent the value of the rows that should be unique for each row)
=IF((Ax>$B$1),Ax,0) in column C
=IF((Ax<$B$2),Ax,0) in column D
=IF(Cx=Dx,1,"") in column E and count the results in column E
Let me know if it is any help!!
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 1

Expert Comment

by:ShriramS
ID: 1615546
You'll probably have to use the DCount or DCountA functions that are provided
0
 
LVL 9

Author Comment

by:antrat
ID: 1615547
I've been trying to use the DCOUNT & DCOUNTA functions
but they still don't accept 2 criteria , or maybe I'm not Writing
them properly . Could please give an example based on my
own example.
0
 
LVL 9

Author Comment

by:antrat
ID: 1615548
Tried using the DCount & DCountA functions but they don't seem to accept 2 criteria either.
0
 
LVL 9

Author Comment

by:antrat
ID: 1615549
Jboddy

        Thanks for your answer. What you have suggested will
work unfortunatley I have something similar in my spreadsheet
now , and I wanted to change the formular to reduce the file size.

0
 
LVL 5

Accepted Solution

by:
vboukhar earned 200 total points
ID: 1615550
You can write your own User defined function to do that. There was same question in experts-exchange some time ago. (for SUMIF function). Look at sample below
Function MyCountIf(WhatSum As Object, R1 As Object, Crit1 As String, R2 As Object, Crit2 As String) As Double
   Col1 = R1.Column
   Col2 = R2.Column
   MyCountIf = 0
   For Each c In WhatSum
     If IsNumeric(Cells(c.Row, Col1)) Then
       MyCheck = Str(Cells(c.Row, Col1)) & Crit1
     Else
       TmpOper = Left(Crit1, 1)
       TmpCrit = Right(Crit1, Len(Crit1) - 1)
       MyCheck = Chr(34) & Cells(c.Row, Col1) & Chr(34) & TmpOper & Chr(34) & TmpCrit & Chr(34)
     End If
     IsCrit1 = Evaluate(MyCheck)
     If IsNumeric(Cells(c.Row, Col2)) Then
        MyCheck = Str(Cells(c.Row, Col2)) & Crit2
     Else
       TmpOper = Left(Crit2, 1)
       TmpCrit = Right(Crit2, Len(Crit2) - 1)
       MyCheck = Chr(34) & Cells(c.Row, Col2) & Chr(34) & TmpOper & Chr(34) & TmpCrit & Chr(34)
     End If
     IsCrit2 = Evaluate(MyCheck)
     If IsCrit1 And IsCrit2 Then
       MyCountIf = MyCountIf + 1
     End If
   Next
End Function
Good Luck!
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question