VLookup Index Match first, second, third

Mark F

Well-known Member
Joined
Jun 7, 2002
Messages
515
Office Version
  1. 365
Platform
  1. Windows
I have a sheet called "Top 100" where I want to vlookup or index match data from a sheet called "USCOTRN"

On the "Top 100" sheet, I want to find first appearance of the value that is in $B4 in Column A on "USCOTRN" sheet and display the value that is in Column F on "USCOTRN" sheet display in column BC (first cell is BC4) on the "Top 100" sheet

On the "Top 100" sheet, I want to find first appearance of the value that is in $B4 in Column A on "USCOTRN" sheet and display the value that is in Column D on "USCOTRN" sheet display in column BD (first cell is BD4) on the "Top 100" sheet

On the "Top 100" sheet, I want to find the second appearance (if there is one) of the value that is in $B4 in Column A on "USCOTRN" sheet and display the value that is in Column D on "USCOTRN" sheet display in column BE(first cell is BE4) on the "Top 100" sheet

On the "Top 100" sheet, I want to find second appearance of the value that is in $B4 in Column A on "USCOTRN" sheet and display the value that is in Column F on "USCOTRN" sheet display in column BD (first cell is BF4) on the "Top 100" sheet

If there are more than two appearance in Column A, id like to use columns BG onwards

I have tried with the code below, but not really getting anywhere, and not fully understanding how to get it to work
Code:
=INDEX(USCOTRN!$A$5:$D$1000,SMALL(IF(USCOTRN!$f$5:$f$1000=B4,ROW(USCOTRN!$f$5:$f$1000)-ROW(USCOTRN!A5)+1),1))

I'd appreciate any help to point me in the right direction

Thanks
Mark :)
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
The ROW(A1) bit is not a good idea. In which do you install the formula you now have?

Hi Aladin

The cell would be cell BC4

Thanks
(and apologies for starting a new question for the VBA part)

Mark
 
Upvote 0
Hi Aladin

The cell would be cell BC4

Thanks
(and apologies for starting a new question for the VBA part)

Mark

This anchoring should work... Control+shift+enter, not just enter, and copy down:

=IFERROR(INDEX(USCOTRN!$F$5:$F$1000,SMALL(IF(USCOTRN!$A$5:$A$1000=B4,ROW(USCOTRN!$F$5:$F$1000)-ROW(USCOTRN!$F$5)+1),ROWS($BC$4:BC4))),"")
 
Upvote 0
This isn't tested, but to change your VBA code to insert the last row, should be something like:

Code:
    LR = Range("a" & Rows.Count).End(xlUp).Row
    Range("BC4").Select
    
    Selection.FormulaArray = _
        "=IF(ISERROR(INDEX(USCOTRN!R5C6:R" & LR & "C6,SMALL(IF(USCOTRN!R5C1:R" & LR & "C1=RC2,ROW(USCOTRN!R5C6:R" & LR & "C6)-ROWS(USCOTRN!R1C1:R4C1)),ROW(R1C1)))),0,INDEX(USCOTRN!R5C6:R" & LR & "C6,SMALL(IF(USCOTRN!R5C1:R" & LR & "C1=RC2,ROW(USCOTRN!R5C6:R" & LR & "C6)-ROWS(USCOTRN!R1C1:R4C1)),ROW(R1C1))))"
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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