Vlookup more than 1 column

rhombus4

Well-known Member
Joined
May 26, 2010
Messages
586
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Is it possible to use Vlookup for multiple colummns or even a range and give the value from the next column

I want to lookup data in column B, E, H and K and if found give the corresponding values in the next column.

i.e if found in E6 it will show the value in F6
 
=IFERROR(INDIRECT(TEXT(SMALL(IF(MOD(COLUMN($B$2:$K$2),3)=2,IF($B$2:$K$10=A1,ROW($B$2:$K$10)*100+COLUMN($B$2:$K$10)+1)),1 ),"R00C00"),0),"Not Found")

=IFERROR(INDIRECT(TEXT(SMALL(IF(MOD(COLUMN($B$2:$K$2),3)=2,IF($B$2:$K$10=A1,ROW($B$2:$K$10)*1000+COLUMN($B$2:$K$10)+1)),1 ),""R00C000""),0),""Not Found"")


Thanks. Not sure how it works

COLUMN($B$2:$K$2),3)=2 - Is B2:K2 the top line of the range

$B$2:$K$10=A1,ROW($B$2:$K$10)*100 - Is B2:K10 the entire range

In the 2 examples above 1st one is * 100 and 2nd is *1000 what does that part do ???

Also what does the R00C00 part do?
 
Upvote 0

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
=IFERROR(INDIRECT(TEXT(SMALL(IF(MOD(COLUMN($B$2:$K$2),3)=2,IF($B$2:$K$10=A1,ROW($B$2:$K$10)*1000+COLUMN($B$2:$K$10)+1)), 1 ),"R00C000"),0),"Not Found")

The COLUMN looks at the column of the range, in this case 2-11. The MOD takes the column number, divides by 3 and returns the remainder. If the remainder is 2, it's a column where the lookup value might be found. Since we're dividing by 3, it means every 3rd column gets checked, 2, 5, 8, and 11.


=IFERROR(INDIRECT(TEXT(SMALL(IF(MOD(COLUMN($B$2:$K$2),3)=2,IF($B$2:$K$10=A1,ROW($B$2:$K$10)*1000+COLUMN($B$2:$K$10)+1)), 1 ),"R00C000"),0),"Not Found")

Now that we've restricted the columns to look at, we look at every cell in the range to see if any of them match A1. If any of them do, we take the row number of it, multiply by 1000, then add the column number, and add one more since we want to return the value to the right of the cell that matches. So if the matching cell is E8, the row is 8, the column is 5, so we get 8000 + 5 + 1 = 8006.


=IFERROR(INDIRECT(TEXT(SMALL(IF(MOD(COLUMN($B$2:$K$2),3)=2,IF($B$2:$K$10=A1,ROW($B$2:$K$10)*1000+COLUMN($B$2:$K$10)+1)), 1 ),"R00C000"),0),"Not Found")

The above process will return a 2-dimensional array containing 1 or more matching row/column number values, or a FALSE value for all the cells that do not match. The SMALL returns the least numeric value, which would be the 8006.


=IFERROR(INDIRECT(TEXT(SMALL(IF(MOD(COLUMN($B$2:$K$2),3)=2,IF($B$2:$K$10=A1,ROW($B$2:$K$10)*1000+COLUMN($B$2:$K$10)+1)), 1 ),"R00C000"),0),"Not Found")

The TEXT function formats a value according the the pattern given. In this case, it turns the 8006 to "R8C006". This is the alternate way of describing a cell, instead of F8, you give it the row and column. Then the INDIRECT returns the value at the reference given, and the (blue) zero parameter tells it to use the R1C1 style of referencing.
 
Upvote 0
Wow. Thanks for the detailed explanation.

Only issue I have is it won't work when looking on a different workbook or even on a different workbook
 
Upvote 0
INDIRECT doesn't work on a closed workbook, but it should work on a different workbook if it's open.
 
Upvote 0
Managed to get it to work in current workbook but wouldn't work in other worknook, even when open
 
Upvote 0

Forum statistics

Threads
1,223,979
Messages
6,175,757
Members
452,667
Latest member
vanessavalentino83

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