View Single Post
  #9   Report Post  
Jerry W. Lewis
 
Posts: n/a
Default return a zero for error

Many languages will allow numbers in place of booleans, and will treat 0 as
False and any other number as True. That permits + to double for Or and * to
double for And. Many threads have used this unstated logic to handle
conditional counts, sums, averages, etc where there are multiple conditions.

You can see the primary representation for booleans in a given language
language by adding zero. Excel's primary numeric representation for TRUE is
1, as seen by
=TRUE+0
VBA's primary numeric representation for TRUE is -1, as seen by
Sub checkIt()
MsgBox True + 0
End Sub

Jerry

"Stefi" wrote:

Hi Jerry,

I tried your solution and it worked, but it's new for me that COUNT(B5:B20)
used as a criterium returns a Boolean value required by the IF function as
first argument, while using as a separate function returns an integer. It
seems that if COUNT(B5:B20) returns zero then its logical value is FALSE, it
it returns a positive integer then its logical value is TRUE. Is it so? How
do you find out such tricks, Help doesn't mention this possibility?

Regards,
Srefi