Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VLOOKUPs with nested IF statement 1

Status
Not open for further replies.

shah25

MIS
Jan 19, 2004
4
GB
=IF(OR(C62={"Tobacco","Cri","Peanuts"}),VLOOKUP(C62,tblFoodType),VLOOKUP(C62,tblProductTypeCode,3,0))

I am trying to insert 1 VLOOKUP if Condition 1 is true and another VLOOKUP if condition 2 is true - but the result
If Tobacco, Cri,Peanuts is true prints out VLOOKUP(C62,tblFoodType) - the formula thinks teh VLookup is a string not an actual formula.

Is there anyway of writing an IF statement thats does this ?

Mo
 
That's because you have entered too few arguments - change your 1st lookup to have the same number of arguments as the 2nd and itshould work fine

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
=IF(OR(C63={"Tobacco","Cri","Peanuts"}),VLOOKUP(C63,tblFoodType,2,VLOOKUP(C63,tblProductTypeCode,3,0)))

Thanks for your response -

I have tried to correct the statement so it contains the correct number of arguments but non of the VLOOKUPS work even though the formulas is accepted into the spreadsheet.

The tables that VLOOKUPs use are both correct.


Mo
 
Hi shah25,

If you've Cut and Pasted that formula (and not made a typo here), the problem is that you don't have a right parenthesis delimiting the first VLOOKUP, so the second one is taken as a parameter to the first.

Enjoy,
Tony

------------------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading FAQ222-2244 before you ask a question.
 
Also, if it is just a typo above, if you just execute the VLOOKUPS without the IF statement, do they work?



[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
Try this:-

=IF(OR(C62={"Tobacco","Cri","Peanuts"}),VLOOKUP(C62,tblFoodType,2,0),VLOOKUP(C62,tblProductTypeCode,3,0))

All I've done is put in the arguments that Geoff pointed out you had missed.

Regards
Ken.............

----------------------------------------------------------------------------
[peace]It's easier to beg forgiveness than ask permission[2thumbsup]

----------------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top