How to test for text in Excel formula

I have a numercal value in A1,
Either Y or N (text cell) is in B1
I want C1 to show the numerical value of A1 if B1 contains the text letter Y
LVL 1
Bill GoldenExecutive Managing MemberAsked:
Who is Participating?
 
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
In cell C1:

=if(B1="Y",A1)
0
 
SunBowConnect With a Mentor Commented:
Gerwin Jansen has provided answer as asked.

Question is, however, incomplete, for it does not mention precondition of C1 or potential alternative for B1. Consider case of B1 being blank or numeric or date or some error. Example text of Z or Yes or N/A or y.

This means asker has to have absolute control of everything on the sheets (including formula that may change B1).

To simplify handling an ELSE condition, it is common to include null or blank space text. Example:

    =if(B1="Y",A1,"")            or          =if(B1="Y",A1," ")

A more robust solution would handle condition of B1 being neither Y nor N.

By not handling the other than Y condition, C1 in Excel yields FALSE which is better used as a boolean than a numeric, leading to potential for problems to arise during development.
0
All Courses

From novice to tech pro — start learning today.