MSGROUPS.NET | Search | Post Question | Groups | Stream | About | Register

### Using Iserror with If statement and Vlookup

• Follow

```I have the following formula in a cell:
=IF(\$K2="STEEL",VLOOKUP(\$B2,'Macos 12 Mo. Data'!\$A\$4:\$AU\$326,40,FALSE),0)

Problem is that the results of this are used for calculations and K2
sometimes doesn't equal "STEEL" so I get an error.  I've tried putting an
Iserror and have the error = 0 but am doing something wrong.  Can you help?
```
 0

```An error would occur if the VLOOKUP can not find a result. Perhaps this:
=IF(\$K2="STEEL",IF(ISERROR(VLOOKUP(\$B2,'Macos 12 Mo.
Data'!\$A\$4:\$AU\$326,40,FALSE)),0,VLOOKUP(\$B2,'Macos 12 Mo.
Data'!\$A\$4:\$AU\$326,40,FALSE)),0)

or

=IF(OR(\$K2<>"STEEL",ISERROR(VLOOKUP(\$B2,'Macos 12 Mo.
Data'!\$A\$4:\$AU\$326,40,FALSE))),0,VLOOKUP(\$B2,'Macos 12 Mo.
Data'!\$A\$4:\$AU\$326,40,FALSE))

--
Best Regards,

Luke M
"juliejg1" <juliejg1@discussions.microsoft.com> wrote in message
news:097C1C90-7B56-467A-AB77-E749B11991E6@microsoft.com...
>I have the following formula in a cell:
> =IF(\$K2="STEEL",VLOOKUP(\$B2,'Macos 12 Mo. Data'!\$A\$4:\$AU\$326,40,FALSE),0)
>
> Problem is that the results of this are used for calculations and K2
> sometimes doesn't equal "STEEL" so I get an error.  I've tried putting an
> Iserror and have the error = 0 but am doing something wrong.  Can you
> help?

```
 0

```Hi,

The way the formula is set up if 'steel' isn't in B2 it will return zero.
What will give an error is not find the value in B2 in the lookup range and
you can get around that by checking if the lookup value is there before
executing the vlookup

=IF(COUNTIF('Macos 12 Mo.
Data'!\$A\$4:\$A\$326,\$B2)>0,IF(\$K2="STEEL",VLOOKUP(\$B2,'Macos 12 Mo.
Data'!\$A\$4:\$AU\$326,40,FALSE),0),"")

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.

"juliejg1" wrote:

> I have the following formula in a cell:
> =IF(\$K2="STEEL",VLOOKUP(\$B2,'Macos 12 Mo. Data'!\$A\$4:\$AU\$326,40,FALSE),0)
>
> Problem is that the results of this are used for calculations and K2
> sometimes doesn't equal "STEEL" so I get an error.  I've tried putting an
> Iserror and have the error = 0 but am doing something wrong.  Can you help?
```
 0

```Thank you Mike....very helpful!

"Mike H" wrote:

> Hi,
>
> The way the formula is set up if 'steel' isn't in B2 it will return zero.
> What will give an error is not find the value in B2 in the lookup range and
> you can get around that by checking if the lookup value is there before
> executing the vlookup
>
> =IF(COUNTIF('Macos 12 Mo.
> Data'!\$A\$4:\$A\$326,\$B2)>0,IF(\$K2="STEEL",VLOOKUP(\$B2,'Macos 12 Mo.
> Data'!\$A\$4:\$AU\$326,40,FALSE),0),"")
>
>
> --
> Mike
>
> When competing hypotheses are otherwise equal, adopt the hypothesis that
> introduces the fewest assumptions while still sufficiently answering the
> question.
>
>
> "juliejg1" wrote:
>
> > I have the following formula in a cell:
> > =IF(\$K2="STEEL",VLOOKUP(\$B2,'Macos 12 Mo. Data'!\$A\$4:\$AU\$326,40,FALSE),0)
> >
> > Problem is that the results of this are used for calculations and K2
> > sometimes doesn't equal "STEEL" so I get an error.  I've tried putting an
> > Iserror and have the error = 0 but am doing something wrong.  Can you help?
```
 0

3 Replies
563 Views

Similiar Articles:

7/28/2012 12:13:29 PM