Solved

IF Statement in Excel returns 0, instead of nothing

Posted on 2011-03-21
4
178 Views
Last Modified: 2012-05-11
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...

0
Comment
Question by:slightlyoff
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 50

Expert Comment

by:Dave Brett
ID: 35186571
>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
 
LVL 24

Expert Comment

by:jimyX
ID: 35186676
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
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 35187603
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
 
LVL 1

Author Closing Comment

by:slightlyoff
ID: 35191289
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

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hash on Excel 13 43
Copy and paste Excel Shapes using vba 6 23
Set a Range to a Cell in Excel VBA 2 15
Look for an number in a column 42 24
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question