How to return a number instead of true/false with an if function?

  • Thread starter Thread starter charles
  • Start date Start date
=IF(your condition,1,2)
eg =IF(A1=B1,1,2) will return a 1 if TRUE, and a 2 if FALSE

--
HTH

Kassie

Replace xxx with hotmail
 
Always elaborate on your issue in the message area (that big white space).
The subject line's just that, meant to be brief keynotes on your issue. It's
NOT your query. Elaborate by posting your formula or your formula attempts
and by describing details of what you have (your sheet set-up, sample data)
and what you want to do/happen

Anyway, here's 2 simple IF examples to groove you in its use ..

In B2: =IF(A2>10,"Yes","No")
B2 will return "Yes" if the check [A2>10] evaluates to TRUE, "No" if FALSE

In B2: =IF(A2>10,200,A2)
B2 will return the number 200 if the check [A2>10] evaluates to TRUE. It'll
return the value in A2 if FALSE

Above any good? hit the YES below
--
Max
Singapore
http://savefile.com/projects/236895
Downloads:27,000 Files:200 Subscribers:70
xdemechanik
 
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
 
Back
Top