Countif using a range comparison

smurphy1977

New Member
Joined
Nov 29, 2010
Messages
3
I am trying to come up with a Countif formual using a range comparison but I don't know if it is possible.

What I a trying to do is to count how many cells differences there are . For example if A1 does not equal B1 then count, if A2 does not equal B2 then count.

A B
1 1
1 2
2 1
2 2

If I had the correct formula in this example I should generate a count of 2.

I just can't get it to work. Can anyone help? Is it even possible?

I was thinking =COUNTIF(A1:A4, "<>B1:B4") but that doesn't work. Doing it that way it counts everthing and gives me a 4

-Sage
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

MrKowz

Well-known Member
Joined
Jun 30, 2008
Messages
6,653
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Try the following:
Excel Workbook
ABCD
1112
212
321
422
Sheet1
Excel 2003
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
I am trying to come up with a Countif formual using a range comparison but I don't know if it is possible.

What I a trying to do is to count how many cells differences there are . For example if A1 does not equal B1 then count, if A2 does not equal B2 then count.

A B
1 1
1 2
2 1
2 2

If I had the correct formula in this example I should generate a count of 2.

I just can't get it to work. Can anyone help? Is it even possible?

I was thinking =COUNTIF(A1:A4, "<>B1:B4") but that doesn't work. Doing it that way it counts everthing and gives me a 4

-Sage

Try...

=SUMPRODUCT((A1:A4<>B1:B4)+0)
 

smurphy1977

New Member
Joined
Nov 29, 2010
Messages
3
Awesome! Would you be able to talk me through the logic because I am trying to wrap my head around it.

I've got = Count (if range 1 does not equal range 2, then ......)

and then I get lost.

And say I wanted to excude any 3's that were in column b in the count what would I add then.
Would it be:

=COUNT(IF(A1:A4<>B1:B4,A1:A4,""))-Count(if(B1:B4=3,1,0) ????

Try the following:

Excel Workbook
ABCD
1112
212
321
422
Sheet1
Excel 2003
#VALUE!
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}. Note: Do not try and enter these manually yourself
 

delaneyjm

Well-known Member
Joined
Apr 22, 2009
Messages
624

ADVERTISEMENT

Bit late as usual...

=SUMPRODUCT(--(A2:A6<>B2:B6))
 

delaneyjm

Well-known Member
Joined
Apr 22, 2009
Messages
624
it converts the true's and false's returned by the A2:A6<>B2:B6 into 1's and 0's. 1 being true and 0 being false.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,041
Messages
5,767,789
Members
425,435
Latest member
cmardaz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top