View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Steve Jackson
 
Posts: n/a
Default Unable to search for a text value with IF

I think I need to explain myself a little further. What I have is 2
worksheets in 1 workbook. Worksheet 1 has several rows of text in 10 columns
(possibly 20 different words can be possible in the cells). In worksheet 2,
the first colum is the list of all the possible words that are in the table
in worksheet 1. In the 2nd column (worksheet 2) I want to run a formula like
this:

Look for the word in Column A (Worksheet 2) and see if it is there in 1 row
of the table in worksheet 1.
If the word exists then run a SUM formula. The SUM formula is purely integer
numbers added and multiplied together so there should be no problem with
this.
If the word does not exist then return either a blank cell or a "0".

Firstly, I have used:
=IF(Test if word is there, Run SUM furmula, 0) -
=IF(Sheet2!A2=Sheet1!B1:B10,SUM Formula,0)

From Pete's good advise I modified this to use the MATCH formula:
=IF(MATCH(Sheet2!A2,Sheet1!B1:B10), SUM Formula,0)

But this returns the #VALUE error when the word I am testing for does not
exist in the row (array).

When I put in the ISERROR function round the MATCH function I just get a
blank cell. I tried altering the formula to:
=IF(ISERROR(MATCH(Sheet2!A2,Sheet1!B1:B10)), SUM Formula,0)

Was this the correct why of using the ISERROR function or can it not be used
in that way?

Steve


"Ken Johnson" wrote in message
oups.com...
Hi Steve,
Looks pretty complicated from here!
Could the ISERROR function help to replace the error message with a 0?
=IF(ISERROR(whatever),0,whatever)
I only use whatever because I'm uncertain which function you will be
using.

Ken Johnson