I have been careful of some If statements (not through any suspicion that Excel might not know what its doing but that I might not, which seems to be the case today).
Hence I would probably have written this as:
=IF(A1>12,IF(A1<40,1,0)) which gives 1
or:
=IF(A1<40,IF(A1>12,1,0)) which also gives 1
In other words, I treat the two conditions separately and then the nested If function can (ha ha:
does) only return a true answer.
But if I enter 10 or 41 I don't get the expected answer either. That is, it answers "False" and not "0" as I expected (but at least "FALSE" is a true response, which in your case it is not).
It appears the IF(AND) statement gives you a 0 or 1 as appropriate and no other approach so far offered.
I don't know whether what I get from my approach is consistent with how Excel behaves or not but in your version I am even less clear what is going on.
JMW