Share via

Apply COUNTIF Function in Multiple Ranges for Same Criteria

Anonymous
2023-11-19T09:12:32+00:00

Hi

Please guide how to combine the following double Countif formula into single Countif function by using AND function.

=COUNTIF($C2:$H2,C2)+COUNTIF($L2:$Q2,C2)=2

Regards

Microsoft 365 and Office | Excel | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2023-11-19T15:54:36+00:00

    =COUNTIF($C2:$H2,C2)+COUNTIF($L2:$Q2,C2)=2

    That doesn't make really a sense, since the criteria in C2 is ALWAYS found in $C2:$H2

    If you want to check that you have only one occurrence in C2:H2 and one in L2:Q2

    R2:  =AND(COUNTIF($C2:$H2,C2)=1,COUNTIF($L2:$Q2,C2)=1)

    Image

    .

    If you want to check if the positions match use

    R2:  =COUNTIFS(C2:H2,C2,L2:Q2,C2)=1

    Image

    .

    Combine them if you want to check both
    R2:  =AND(COUNTIF($C2:$H2,C2)=1,COUNTIF($L2:$Q2,C2)=1,COUNTIFS(C2:H2,C2,L2:Q2,C2)=1)

    Image

    .

    Andreas.

    1 person found this answer helpful.
    0 comments No comments
Answer accepted by question author
  1. Anonymous
    2023-11-19T13:43:37+00:00

    Hi FazliWahid,

    Thank you for reaching out. My name is Leo, a user just like you. I'd be happy to help you with your concern.

    I have modified your formula, kindly try it and see if it works.

    =AND(COUNTIF($C2:$H2,C2)>0, COUNTIF($L2:$Q2,C2)>0)

    If both conditions are true, the AND function returns TRUE. Otherwise, it returns FALSE.

    Your understanding and patience will be highly appreciated. I hope I provided a helpful information regarding your concern! Let me know if you have any further questions. Be safe always!

    Best Regards,

    Leo

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful