VLOOKUP AND FIND THE SECOND MATCH

Deano

Active Member
Joined
May 2, 2004
Messages
264
Hi

Can I modify a VLOOKUP formula to not find the first match, but the second, third, etc.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi,

Formula needs to be entered with Ctrl + shift + enter.
Index range must always start at row 1 wherever your data is.
Book1
ABCDEF
1LookupvalMatch
2a10a110
3a11211
4b12313
5a13
6c14
Sheet6
 
Upvote 0
Thanks very much, works great on my test data.

I'm going to have to play with this one to fully understand how it works.

Cheers
 
Upvote 0
HMMM thanks, is there an easier way to do it. Or atleast could you kindly explain the formula structure.
 
Upvote 0
I think the formula is pretty straight forward. The IF statement gives you an array of the row numbers for the rows that have a match. SMALL gives you the the occurenc you specify. The result is used in INDEX to give you the value.

An easier way could be using a UDF called vlookupnth that you can find searching this board.
 
Upvote 0
Hello, Quick question the formula works nicely, but why must it only work when the table is in row one (1)?

Thanks,
Nawaf
 
Upvote 0
countryfan_nt said:
Hello, Quick question the formula works nicely, but why must it only work when the table is in row one (1)?

Thanks,
Nawaf


The table can be any where you must just start the range for INDEX in row 1

E.g. if table is A10:A20 you use A1:A20 as the range for INDEX.
 
Upvote 0
Sorry to resurrect this thread but I am trying to use the UDF suggested and am having trouble

The problem with this is that my lookup isnt an exact match to the list it looks to

I have managed to doctor a vlookup function so that it looks for the item anywhere in the string using the following formula:

=VLOOKUP("*" & A1 & "*",'Sheet1'!D2:J241,7,FALSE)

However if i try and use the same sort of thing within the UDF or even the Index formula it returns no result. I am assuming that is because it doesnt recognise what I am looking for ie "*" & A1 & "*", but it is strange that the vlookup formula will recognise it

Any help appreciated
 
Upvote 0
countryfan_nt said:
Hello, Quick question the formula works nicely, but why must it only work when the table is in row one (1)?

Thanks,
Nawaf


The table can be any where you must just start the range for INDEX in row 1

E.g. if table is A10:A20 you use A1:A20 as the range for INDEX.

You can avoid that 'prerequisite' easily though:

=INDEX($B$10:$B$20,SMALL(IF($A$10:$A$20=$D$2,ROW($A$10:$A$20)-ROW($A$10)+1),$E$2))

which needs to be confirmed with control+shift+enter.

Note that D2 houses a lookup value and E2 an instance number, e.g., 2.
 
Upvote 0

Forum statistics

Threads
1,215,336
Messages
6,124,331
Members
449,155
Latest member
ravioli44

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