vlookup with if statement

blackduck

New Member
Joined
Sep 27, 2017
Messages
7
hi, I need some help with a vlookup, any help would be greatly appreciated!

I need to look at column 1 and return the value specified in the lookup table, but if the number doesn't exist in column 1 lookup table, i want to lookup column 2 and return the value based on the lookup table. Any ideas how i write this?

EXAMPLE DATA with last column being what i want to be generated by the formula:
Column 1Column 2RETURNED VALUES
1dblue
2ered
3fyellow
4dgreen
5eorange
6fblack



<colgroup><col span="2"><col></colgroup><tbody>
</tbody>

LOOKUP TABLE:
Column 1Column 2Result
1blue
2red
3yellow
dgreen
eorange
fblack


<colgroup><col span="2"><col></colgroup><tbody>
</tbody>



THANK YOU SO MUCH FOR YOUR HELP!!
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Black,

Try

Code:
=IFNA(VLOOKUP(A2,A10:C15,3,0),VLOOKUP(B2,B10:C15,2,0))
 
Upvote 0
PERFECT - thank you so much!!! One last question, how do i adjust the formula so if the thing i am looking up is not in either lookup column then it shows returns a particular work e.g. 'PINK'
 
Upvote 0
This worked for me;

Code:
=IFNA(IFNA(VLOOKUP(A2,$A$11:$C$18,3,0),VLOOKUP(B2,$B$11:$C$18,2,0)),"PINK")

** Note that the lookup ranges are now locked eg $A$11:$C$18, remember to increase the range when you add more data.
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top