Vlookup

dcyuen

Board Regular
Joined
Jun 2, 2008
Messages
56
Hi guys, i have a question about vlookup:

[FILE A]
A B C
1 Order# Start time End time
2 12345 9:00 AM 10:00 AM
3 12345 10:00 AM 11:00 AM
4 23456 11:00 AM 13:00 PM
5 34567 13:00 PM 15:00 PM

[FILE B]
I want to Vlookup FILE A, order# 12345 as the below:
start time is 9:00 AM & End Time is 11:00 AM

How to avoid Vlookup duplicated order#? Thanks.

-Donald
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Thanks. Hey i remember you helped me last time! Sorry I do not exactly understand. Let say if I have a massive order# in File A, how could I Lookup the first Start-Time and the last End-Time of Order#,12345?
Thanks a lot!
 
Upvote 0
Here's one way:
Book1
ABCDEFG
1Order#Start timeEnd timeEarliest StartLatest End
2123459:0010:00123459:0011:00
31234510:0011:002345611:0013:00
42345611:0013:00
53456713:0015:00
Sheet1


Instead of VLOOKUP, I've used the combination of INDEX and MATCH. The formula in column F accomplishes what Aladin's VLOOKUP suggestion would have. The formula in column G is a little different. When searching through a list of numbers, if the MATCH function finds an entry equal to the number for which it is searching, the function returns the row number of the first such entry. Otherwise it returns the row number of the last entry less than the number for which it is loooking. To take advantage of this behaviour, the formula in column G is looking for a number slightly bigger than the order number. It won't find 12345.1 in the list, so instead it will return the row number of the last time it finds 12345 in the list.
 
Upvote 0
Thank you very much and your fast reply! I am working in Hong Kong right now so is day time over here. But I do used to live in Arizona before.
Everything is working and I get the concept, but one thing I don't unstand is when there are 2 numbers that are the same, why INDEX only address the the first one?
 
Upvote 0
...when there are 2 numbers that are the same, why INDEX only address the the first one?

The reason is that the MATCH and LOOKUP functions don't have a way for you to tell it "There will be more than one valid result, show me the nth one". (Unlike, for example, the SUBSTITUTE function, where you can replace the nth instance of your search string.) So, we have to set up the search criteria in a way that forces the single result to be the one we want. Also, I forgot to mention that your data has to be sorted by order number for my formula to work.
 
Upvote 0
Oh, the order# is entered by the operator and is not in sorted order.

Any other solution to solve the END-Time lookup? I still having trouble lookup the END-TIME with the formula, it results random END-TIME for some reason -_- Please advice and thanks!
 
Upvote 0
You want the last end time from the table, i.e. the one associated with the last instance of that specific order number in the table (which isn't necessarily the latest time)?

Try

=LOOKUP(2,1/(order_number_range=order_number),end_time_range)
 
Upvote 0
Thanks for your reply.

Error: #NUM! (cannot enter as A:A, must be a given range)

Nevermind, it's working! that's amazing, how that happen? Thansk!
 
Last edited:
Upvote 0
Thanks for your reply.

Error: #NUM! (cannot enter as A:A, must be a given range)

Nevermind, it's working! that's amazing, how that happen? Thansk!

Would you please state the lookup value (or values if more than one) and the expected result with respect to the initial sample you posted?
 
Upvote 0

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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