IF Then HELP!!!!

G

Guest

Hi, I need help from someone who can help me write a formula that will look
in a cell (ex. A2) read the contents of the cell and if any of a certain type
of word is listed then print that word or just print the word check.

I have been trying something like this
Example cell A2 has ./....blue...yellow in the same cell. I want it to find
check for each color i list in the formula....ie...red, green, yellow, blue,
purple..etc. but only fill in the colors that do appear.

IF(ISNUMBER(SEARCH("red",A2)),"RD","CHECK")

the problem I have is getting it to check for the rest of the colors in the
same cell with this formula...Kind of an if this statement is true print "RD"
and look for the next color, if false then check for the next color....and
so. If anyone knows of a way to do this it would help me out a lot. Thank you
and be blessed for all of your help in this.
 
G

Guest

put in a regular module

Function myColor(myCell)
Dim c1
Application.Volatile
If InStr(1, myCell, "red") > 0 Then c1 = "red"
If InStr(1, myCell, "blue") > 0 Then c1 = "blue"
If InStr(1, myCell, "green") > 0 Then c1 = "green"
If InStr(1, myCell, "black") > 0 Then c1 = "black"
If InStr(1, myCell, "yellow") > 0 Then c1 = "yellow"
'If InStr(1, myCell, "another color") > 0 Then c1 = "another color"
'If InStr(1, myCell, "another color") > 0 Then c1 = "another color"
'If InStr(1, myCell, "another color") > 0 Then c1 = "another color"
'If InStr(1, myCell, "another color") > 0 Then c1 = "another color"
If c1 = "" Then c1 = "No match"
myColor = c1
End Function

In ur sheet use it this way:

=mycolor(a1)
or
=mycolor(sheet1!a1)

"Nimrod" skrev:
 

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