I need to use the regular vlookup but return the values in columns 16, 17, 18.
If you're returning three columns related to one lookup term, note that there is a much more efficient way of doing this - particularly if you have hundreds or thousands of lookups that are returning data from very very large tables.
Here' some draft content from the book I'm working on -
Excel for Superheroes and Evil Geniuses - that discusses this:
Let's say you want to look up a CustomerID from some Database Table, and return multiple columns associated with that record:
Now let’s look in turn at what each of those three VLOOKUPS is doing.
- The first VLOOKUP spends most of its time scanning the ID column of the Lookup Table in order to find the row (if any) that contains a match, then grabs the corresponding value from the 2nd column of that row.
- The second VLOOKUP spends most of its time scanning the ID column of the Lookup Table in order to find the row (if any) that contains a match, then grabs the corresponding value from the 3rd column of that row.
- The third VLOOKUP spends most of its time scanning the ID column of the Lookup Table in order to find the row (if any) that contains a match, then grabs the corresponding value from the 4th column of that row.
Wait a minute: Those VLOOKUPS are stupid. In fact, I’m going to tell them they’re stupid:
You mean to tell me that you three VLOOKUPS each spent most of your effort looking up the address of the very same customer ID? Man, you guys are dumb! Why didn’t just one of you find out the relevant row, and pass that information on to the others? That would have saved two of you from doing time-consuming searches!
What we need is a non-selfish ‘scout’ function that goes off and finds exactly where something is in a lookup table, and then shares it's information with other functions. Let’s call this hypothetical function the “MATCH” function.
And then all we need is another type of lookup function – let’s call this hypothetical beast the “INDEX” function – that is happy to be told where to look for something. In fact, if we had three of these INDEX beasts, we could simply say to them:
- You there: your job is to point at the FirstName column
- And you: your job is to point at the LastName column
- And lastly you. Yes, you. Your job is to point at the BirthDate column.
- Now all of you listen up: MATCH will be returning from his scouting mission at any moment. He will tell you shortly exactly which row I want from the particular column you’re pointed at. So don’t muck around trying to work it out yourself, because I’m in a hurry.
Well, what do you know…Excel already
has functions called MATCH and INDEX. Let’s see if they help us here.
