How can I test the text content of a cell

C

catefaulkes

I wish to create a logical test - an IF statement that tests whether a cell
contains H, M or L, and output the result as a number.
I cannot get the IF statement to recognise text as true or false - my Excel
2007 gives an error when I try to do something like IF(E9=H ....) is there a
way to do this?
 
F

Fred Smith

For Excel to recognize text, you need to surround it in quotes, like this:
=if(or(e9="H",e9="M",e9="L"),true,false)

Regards,
Fred
 
M

Mike H

Hi,

You don't say if you want a different number for each of the text values or
the same number so we'll start with the same number

=IF(OR(A1="H",A1="M",A1="L"),99999,"")


--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.
 
M

macropod

Hi catefaulkes,

Yet another approach:
=(E9="H")*1+(E9="M")*2+(E9="L")*3
Replace the 1,2,3 with whatever values you require. If no match occurs, 0 is returned.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top