...
Aladin, your tight compact answers always interest me.
Thanks. It's better/more efficient for the current task to invoke Count instead of SumProduct though.
I am curious as to why in
=(SUMPRODUCT(ISNUMBER(A1:A5)+0)=ROWS(A1:A5))+0
You used +0 Twice. It looks like you used it once to coerce the isnumber() result and once to coerce the final sumproduct(). I assumed your final sum product would already be a number and not need to be coerced to be a number.
The first +0 coerces the result array IsNumber return into a numeric array of 1/0's. The second +0 coerces the result of the equality test:
SUMPRODUCT(...)=ROWS(...)
If you remove the last/outer +0, the final evaluation would be either TRUE or FALSE. Coercing this to 1/0 is easier to process for it's a number and in addietion, you can custom format the formula cell as:
[=0]"Not All Numbers";[=1]"All Numbers"
Also why are you using +0 in this case as opposed to --
I have been following some of your work for a while and have kept this link
http://www.mrexcel.com/board2/viewtopic.php?p=345161#345161
as a reference. The way I and other have read and referenced it in the past was that if one is going to coerce the sumproduct() use -- not +0 or even *1
The temporal profiling I've done shows -- and +0 as (almost) equal. I think I reported this observation in the link you quote. As to why +0 here? I tend to use +0 when there is a single array to process. Also, when a text date must be coerced. Thus:
>="1-Jan-04"+0
instead of
>=--"1-Jan-04"
I have used variations of your sumproduct() answers to replace large/many array formulas in the past to improve over all speed calculations. Unfortunately the logic is always harder for me to grasp then an array formula and an if() statement. Any tips on getting one's mind to think though sumproduct() instead of array formulas?
Actually, both types of formulas follow the same logic:
[1]
{=SUM(IF(A2:A10="X",IF(B2:B10="Y",1,0),0))}
[2]
{=SUM((A2:A10="X")*(B2:B10="Y"))}
[3a]
=SUMPRODUCT((A2:A10="X")*(B2:B10="Y"))
[3b] Reverting back to the comma syntax with explicit coercion added:
=SUMPRODUCT(--(A2:A10="X"),--(B2:B10="Y"))
As you see from [1] and [2], you need to rewrite IF in a binary form:
IF(A2:A10="X",IF(B2:B10="Y",1,0),0)
==>
(A2:A10="X")*(B2:B10="Y")
==> (when fed to SumProduct)
--(A2:A10="X"),--(B2:B10="Y")
Whenever you can take this step, you can construct an equivalent SumProduct formula.
Out of curiosity is there a logical easy way to do my original formula {=IF( (ISNUMBER(a1:a5)="TRUE"),"number", "numbers and letters")}
but compare it to some sort of an array and get correct results?
{=IF(AND(ISNUMBER(A1:A5)),"number", "numbers and letters")}