Countif without CSE, unpredictable behavior

crazykvex

New Member
Joined
Feb 6, 2016
Messages
2
I've stumbled upon a feature of Excel which I do not understand. In the table below I've tried to strip down my issue to its bare essence:

XCOUNTIF(A1,A3:A4) evaluates to: 0F9: {1,0} evaluates to: 1INDEX(COUNTIF(A1,A3:A4),1,1) evaluates to: 1
COUNTIF(A1,A3:A4) evaluates to: 0F9: {1,0} evaluates to: 1INDEX(COUNTIF(A1,A3:A4),1,1) evaluates to: 1
XCOUNTIF(A1,A3:A4) evaluates to: 1F9: {1,0} evaluates to: 1INDEX(COUNTIF(A1,A3:A4),1,1) evaluates to: 1
YCOUNTIF(A1,A3:A4) evaluates to: 0F9: {1,0} evaluates to: 1INDEX(COUNTIF(A1,A3:A4),1,1) evaluates to: 1

In the second column, COUNTIF is used to find the values in cells A3:A4 in cell A1 (NOT as an array formula, so no CSE).
The result puzzled me: it was zero, unless the formula is entered on the third line (the same line containing the match).

My main question is
Main Question: what is Excel's evaluation sequence of COUNTIF(A1,A3:A4) and why does it lead to different results based on the row in which the formula is entered?

I also noticed that if I evaluate the formula of each cell separately using F9, the answer is always {1,0}, and after hitting ENTER, the answer is always 1
Bonus Question 1: How can evaluating an equation using F9 change the result?

When the formula is surrounded by INDEX(...,1,1) the problem is solved, a method I stole from Aladin
Bonus Question 2: How does Aladin's workaround solve the row-depencence problem?

Can somebody help me with my (preferably the main!) question?
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Small change on the first post: the INDEX(...,1,1) formulas should be INDEX(...,0,0). Unfortunately I am not allowed to change this in the post itself, that's why I post it separately. Sorry for the confusion.
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,285
Members
449,218
Latest member
Excel Master

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
Back
Top