# Microsoft Office Application Help - Excel Help forum > Excel Formulas & Functions >  >  If a cell has certain text then return value?

## Flash101

How do i write an If function where if a cell has a certain text in it, it would return a value to onather cell.

For instance:
If cell B1 has "red" in it the cell B4 must be "6"
If cell B1 has 'blue" in it, then cell B4 must be "7"
and so on with certain text returning a certain value?

Please can you help me?

----------


## DonkeyOte

Depending on how many strings you have...

=IF(B1="red",6,IF(B1="blue",7,0))

If you have lots then list the colours in one column, say C1 onwards (red,blue etc..) and the associated values in an adjacent column, say D1 onwards (6,7 etc...) then:

=VLOOKUP(B1,C:D,2,0)

Going forward please ensure you post in the most relevant forum - I have moved this from Outlook Forum to Excel Worksheet Functions.

----------


## Flash101

Thanks, you have solved my problem.
Many thanks.

----------

