Creating Function to Reference Cells that Contain Certain Values

S

Seraslynz

I want to insert a function, I assume an "IF" function that gives me back
different values depending on if the referenced cells contain certain
information.

For example:

A2: FS2-670-SB

If A2 contains the letters "SB" then the function with return "SMBS"

I want to do multiple IF functions so that depending on the "key" letters,
the function will return a certain answer

So, If the cell contains "SB" then return "SMBS", if cell contains "SMB"
cell returns "SMBS", if cell contains "SS" then return "SHIN", if cell
contains "BB" then cell returns "BBUL" etc.
 
T

T. Valko

One way...

Create a 2 column table like this:

SB...SMBS
SMB...SMBS
SS...SHIN
BB...BBUL

Assume that table is in the range G2:H5

A2 = FS2-670-SB

Enter this array formula** in B2:

=IF(COUNT(SEARCH(G$2:G$5,A2)),LOOKUP(1E100,SEARCH(G$2:G$5,A2),H$2:H$5),"")

** array formulas need to be entered using the key combination of
CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT
key then hit ENTER.
 
J

Jacob Skaria

Try the below (Case sensitive..)

=IF(ISERROR(FIND("SB",A2)),IF(ISERROR(FIND("SMB",A2)),IF(ISERROR(FIND("SS",A2)),IF(ISERROR(FIND("BB",A2)),"","BBUL"),"SHIN"),"SMBS"),"SMBS")

If this post helps click Yes
 
S

Seraslynz

One more question to add on, because that function did work:

If I have a function that contains "SB MS" or "SB MSD" I need it to return
blank (a quality control test... how would I work that into the function?

Thanks!
 
J

Jacob Skaria

=IF(ISERROR(FIND("SB MS",A2)),IF(ISERROR(FIND("SB",A2)),
IF(ISERROR(FIND("SMB",A2)),IF(ISERROR(FIND("SS",A2)),
IF(ISERROR(FIND("BB",A2)),"","BBUL"),"SHIN"),"SMBS"),"SMBS"),"")

If this post helps click Yes
 
S

Seraslynz

Thanks for the help, but now with this:

=IF(ISERROR(FIND("BB MSD",H3264)),IF(ISERROR(FIND("BB
MS",H3264)),IF(ISERROR(FIND("SB MSD",H3264)),IF(ISERROR(FIND("SMB
MSD",H3264)),IF(ISERROR(FIND("SB",H3264)),IF(ISERROR(FIND("SMB",H3264)),IF(ISERROR(FIND("SS",H3264)),IF(ISERROR(FIND("BB",H3264)),"","BBUL"),"SHIN"),"SMBS"),"SMBS"),""),""),""),"")

It says "The specified formula cannot be entered because it uses more levels
of nesting than are allowed in the current file format" -- any ideas on how I
can change my file format to accomodate?
 

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