VLookup (perhaps) - Returning first non-blank cell in row relative to reference

husar

New Member
Joined
Sep 27, 2016
Messages
6
Hello Community Members,

I have searched the forum for the answer to this conundrum, but cannot seem to find it. If you know the answer (or where I can find the answer) to the following scenario, then please post below.

Here is a simplified version of the excel spreadsheet that I am working with currently:
IDColumn AColumn BColumn C
16010
13020
10409
2508
210608
3117
4706
435805

<tbody>
</tbody>

I would like to pull a value from "Column B" (or any column after ID) with a reference to the ID. As you can see, the ID numbers are on there multiple times, and sometimes the first corresponding variable cell in column B is blank. What type of formula can be created that will reference ID 1 (for example) and pull the first non-blank variable still attached to ID 1 (which would be "20" in this case). I do not want it to pull any variable not attached to the reference ID. For example, the first cell for ID 3 in column B is blank, but the next ID is 4 and thus the cell with "70" should not be pulled b/c it is not associated with ID 3.

Hopefully this makes sense. I can clarify if not. Any feedback/help would be appreciated! Thank you!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Can you post what way you want the table to look (i.e. post formula)?
 
Upvote 0
Something like this might work:

ABCDEFGHI
1IDColumn AColumn BColumn CIDColumn AColumn BColumnC
216010311No Match7
313020
410409
52508
6210608
73117
84706
9435805
10

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet7

Array Formulas
CellFormula
G2{=IFERROR(INDEX(B:B,MIN(IF(($A2:$A9=$F$2)*(B2:B9<>""),ROW(A2:A9)),9^9)),"No Match")}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



Put the formula in G2, and confirm with Control+Shift+Enter. Then copy that cell to H2 and I2. Let me know if this is the type of thing you're looking for.
 
Upvote 0
Hi Eric,

Thanks for the reply! The formula worked great for the first row. However, if I add other IDs in the following rows and copy the formula down (instead of across), the resulting numbers are incorrect.
In other words, if I add in the other IDs into column F and drag down the formula, it looks like this:

F G H I
3 11 nomatch 7
1 11 nomatch 7
2 11 nomatch 7
4 11

Putting "$" around some of the variables will probably fix this, so I was going to play around with it. While I do, any suggestions?

Thank you!
 
Upvote 0
Just remove the $ in red:

=IFERROR(INDEX(B:B,MIN(IF(($A2:$A9=$F$2)*(B2:B9<>""),ROW(A2:A9)),9^9)),"No Match")
 
Upvote 0

Forum statistics

Threads
1,215,356
Messages
6,124,475
Members
449,164
Latest member
Monchichi

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