# IF Statement in Excel returns 0, instead of nothing

I have this value in my excel worksheet:
=IF((ISNUMBER(FIND("BD",'Sheet1'!\$C34))),'Sheet1'!Y34,"")

If Excel finds "BD", I get the value in "Sheet1, cell Y34".  (Works gret)

If it doesn't find "Fred" I get a 0. (Not what I want)

What I would like it to do is return a blank value, or no value - otherwise I get zeros all over the place - and 1/0/1900 for any date columns.

Is there a better way to check to see if a column contains a string of letters?  In my case, I have a sheet filled with values where some start with BD or AD but have different numbers after that.  I need to be able to grab just the cells that have a "BD"

I hope that makes sense...

LVL 1
###### Who is Participating?

Commented:
If you get a zero with that formula that's in fact because BD is found but Y34 is blank.

Try changing to this version which will also allow zero when that's a valid return

=IF(ISNUMBER(FIND("BD",'Sheet1'!\$C34)),IF('Sheet1'!Y34="","",'Sheet1'!Y34),"")

regards, barry
0

Commented:
>Is there a better way to check to see if a column contains a string of letters?

Regardless of your test, you need to return a negative result then you then need to clean up

One way - without code - would be to introduce a deliberate error than can be wiped out quickly

1)  use a formula like this =IF((ISNUMBER(FIND("BD",'Sheet1'!\$C34))),'Sheet1'!Y34,NA())
to return NA() rather than"" for no match
2) select your area of formlae
3) Press F5   .... Special
4) Then check "Errors" under "Formulas"
5) This selects only the NA() cells (ie the non strings), which you can delete win a single shot

Cheers

Dave
0

Commented:
Find (or Search) are the best to check the strings for sub-string.

You need to use ISERROR instead:
=IF((ISERROR(FIND("BD",'Sheet1'!\$C34))),"",'Sheet1'!Y34)
0

Author Commented:
Thank you.  This produced exactly what I was looking for.

The other 2 solutions acutally produced the same thing I had, but I may have done something incorrectly.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.