If Then assistance...

M

Murph

I'm just not computing this simply in my mind. I want a formula/macro that
will check cell F2 for multiple terms (blue, red, green, yellow) then input a
number in cell G2 to reflect that color (blue = 1, red = 2, green = 3, yellow
= 4).

I have not had enough coffee today obviously because this seems like a
simple task and I'm just not grasping it. Excel 07 also.
 
R

Rick Rothstein \(MVP - VB\)

I think you are looking for this...

=MATCH(F2,{"blue","red","green","yellow"},0)

Rick
 
M

Marcelo

Hy Murph,

if you have on cell F2 the text blue, red, yeloow etc

you can use +if(f2="Blue",1,if(f2="red",2,if(f2="green",3,if(f2="yellow",4))))

if you are looking fot a value regarding the pattern of the cell, look at a
Chip Pearson page at:
http://www.cpearson.com/excel/SortByColor.htm

hth
--
regards from Brazil
Thanks in advance for your feedback.
Marcelo



"Murph" escreveu:
 
C

CLR

The VLOOKUP function will do this nicely. Create a table, listing the colors
down one column and the corresponding numbers in the cells in the column just
to the right of it. Name the table "MyColors". Then put this formula in
cell G2

=VLOOKUP(F2,MyColors,2,FALSE)

Vaya con Dios,
Chuck, CABGx3
 
R

Ron Coderre

This formula returns the number index of the color in F2
.....or zero if F2 is either blank or contains invalid text:

G2: =MAX(COUNTIF(F2,{"blue","red","green","yellow"})*{1,2,3,4})

Does that help?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)
 

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