VLOOKUP the first result, then the second, then the third....

ThatExcelLife

New Member
Joined
Nov 2, 2017
Messages
18
Hey guys

Firstimer here! Woohoo!

I got an interesting problem. What I am trying is to do create a formula for which VLOOKUP will use column A in Exhibit 1, vlookup the info from Exhibit 2 and return the value in column B Exhibit 2. There is an extra vlookup that will use the contract number to find the machine number, and the machine number will then look up the category number, so 0997550216 to UG to 1201. Now a simple vlookup will do the 1201 nicely. The problem is vlookup ONLY looks and takes the first value it finds! What I need the formula to do is now, where the question mark is in exhibit 1, return the SECOND category number, or 1217 from Exhibit 2. What could I do so in Exhibit 1, I can have a formula I can simply pull down based on the contract number in column A and excel returns the first, second, third categories as needed? Something like a "If vlookup result is the same in cell above, then take the next available one"? I don't know. Its a tricky one.

Exhibit 1
CONTRACT

<tbody>
</tbody>
CATEGORY

<tbody>
</tbody>
0997550216

<tbody>
</tbody>
1201

<tbody>
</tbody>
0997550216

<tbody>
</tbody>
?
0997550218

<tbody>
</tbody>

<tbody>
</tbody>

Exhibit 2
MACHINE

<tbody>
</tbody>
CATEGORY

<tbody>
</tbody>
UG

<tbody>
</tbody>
1201

<tbody>
</tbody>
UG

<tbody>
</tbody>
1217

<tbody>
</tbody>
CAID

<tbody>
</tbody>
1301

<tbody>
</tbody>

<tbody>
</tbody>
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Thanks for the welcome!

There is a third exhibit that serves as a mapping of sorts, so my current vlookup would be =VLOOKUP(VLOOKUP(A2,Exhibit 3$A:$B,2,FALSE) Exhibit 2$A:$B,2,FALSE). This goes from 0997550216 to UG to 1201.
 
Upvote 0
There is a third exhibit that serves as a mapping of sorts

OK thanks, here is one option that you can try to adapt to your actual set-up:


Excel 2013/2016
ABCDEFGH
1Exibit 1Exibit 2Exibit 3
2CONTRACTCATEGORYMACHINECATEGORYContractMachine
39975502161201UG1201997550216UG
49975502161217UG1217997550218CAID
59975502181301CAID1301
Sheet1
Cell Formulas
RangeFormula
B3=INDEX($E$3:$E$100,AGGREGATE(15,6,(ROW($E$3:$E$100)-ROW($E$3)+1)/($D$3:$D$100=VLOOKUP(A3,$G$3:$H$4,2,0)),COUNTIFS(A$3:A3,A3)))
 
Upvote 0
HOW did you figure this out!?! Its works perfectly! You know how long I have been attempting to think this through? Wow a HUGE thanks to you, MrExcel MVP. Really helps me out. Please chalk this problem up as SOLVED.
 
Upvote 0

Forum statistics

Threads
1,215,608
Messages
6,125,820
Members
449,265
Latest member
TomasTeix

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