Using OR function with VLOOKUP

tobes21

Board Regular
Joined
Jun 4, 2003
Messages
93
I was wondering if it is possible to do a VLOOKUP where the lookup_value can be more than one value. I tried using an OR function but that didnt seem to work. I would like the VLOOKUP function to work for any of the values of text "M", "SC", "SH", "ODC". Here is my formula:

=VLOOKUP(OR("M","SC","SH","ODC"),'Cost Detail'!$D6:$G45,3,FALSE)
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I switched the formula to:

=IF(OR('Cost Detail'!D6={"M","SC","SH","ODC"}),OR('Cost Detail'!$F6:$F45,OR('Cost Detail'!D6)),"")

And now I get #VALUE!
 
Upvote 0
tobes21 said:
I switched the formula to:

=IF(OR('Cost Detail'!D6={"M","SC","SH","ODC"}),OR('Cost Detail'!$F6:$F45,OR('Cost Detail'!D6)),"")

And now I get #VALUE!

Why don't you try...

=IF(OR('Cost Detail'!$D6={"M","SC","SH","ODC"}),INDEX('Cost Detail! $G1 :$G45,ROW('Cost Detail'!$D6)),"")

If you want return from the F-range in Cost Detail...

=IF(OR('Cost Detail'!$D6={"M","SC","SH","ODC"}),INDEX('Cost Detail! $F1 :$F45,ROW('Cost Detail'!$D6)),"")

and report back what you get?
 
Upvote 0
One more quick question if I may. Suppose I want to have the same exact thing happen, but only for one selection, specifically "T". instead of 4 different ones. So if "T" is selected in the drop down box, I want the number in row F to appear on my sheet.
 
Upvote 0
tobes21 said:
One more quick question if I may. Suppose I want to have the same exact thing happen, but only for one selection, specifically "T". instead of 4 different ones. So if "T" is selected in the drop down box, I want the number in row F to appear on my sheet.

That would be simply...

=INDEX('Cost Detail! $F1 :$F45,ROW('Cost Detail'!$D6))

with D6 housing "T".

Or, if you want to make sure that it is "T" that is looked up...

=IF('Cost Detail'!$D6="T",INDEX('Cost Detail! $F1 :$F45,ROW('Cost Detail'!$D6)),"")
 
Upvote 0
It works, but it only seems to work for the first row that I apply it to. It turns out that the same things happens for the other one with the 4 different choices. Say in D6 of 'Cost Detail' I have "T" and in F6 I have "1.1", it puts "1.1" on the correct sheet just fine. Also if I then go to D7 and choose "SC" and "1.2" in F7 that works fine too. But say I go to D8 and choose "T" and 1.2 it gives me a "-" on the appropriate cell in the sheet it is supposed to go into.
 
Upvote 0
tobes21 said:
It works, but it only seems to work for the first row that I apply it to. It turns out that the same things happens for the other one with the 4 different choices. Say in D6 of 'Cost Detail' I have "T" and in F6 I have "1.1", it puts "1.1" on the correct sheet just fine. Also if I then go to D7 and choose "SC" and "1.2" in F7 that works fine too. But say I go to D8 and choose "T" and 1.2 it gives me a "-" on the appropriate cell in the sheet it is supposed to go into.

Care to post 10 rows from Cost Detail?
 
Upvote 0

Forum statistics

Threads
1,222,716
Messages
6,167,823
Members
452,146
Latest member
Baldred

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