View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.newusers
Ed Ferrero[_3_] Ed Ferrero[_3_] is offline
external usenet poster
 
Posts: 108
Default How to return a number instead of true/false with an if function?

Hi Charles,

You have had a couple of good answers already.

In general, if a function or expression evaluates to TRUE/FALSE, you can
convert it to 1/0 by multiplying by 1.

So
=A1=4
will return TRUE or FALSE depending on the value entered in cell A1, and
=1*(A1=4)
will return 1 or 0 based on the value in cell A1

That means that you can write
=IF(A1=B1,1,0)
or
=1*(A1=B1)
to show 1 or 0 if A1=B1

Ed Ferrero
www.edferrero.com