Indefinite/ Multiple Vlookups until hit blank column.

tgray1

New Member
Joined
Sep 19, 2017
Messages
2
IDVlookups?Col1Col2Col3Col4
13445
220252930
310

<tbody>
</tbody>

Hi All - I have the following table. First column is an ID. The following columns (ignoring Vlookups) are a number of additional IDs that relate to the IDs in the column. (e.g. IDs 34 and 45 are inputs for ID 1).

I'm looking for some formula that can vlookup the IDs in Col1, Col2, etc and return the Names of the ID - The Names of the ID are in another tab, simple two column list A = IDs, B = Names.

My difficulty is how to tell the vlookup up formula to keep adding the fomula until it hits a blank Column - e.g. no more related IDs.

For example,
row 1 will return "ID34 Name; ID45Name"
row 2 will return "ID20 name; ID25 name; ID29 name; ID30 name"
row 3 will return "ID10"

I'm not being lazy btw, some rows in my data have 45 related IDs (split into 45 columns) and other rows only have 2.

Thanks.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the forum.

Excel has a hard time concatenating variable size arrays. Using basic functions, you could create 45 additional columns to the right of the ID columns, each of which looks up the ID if it's there, and concatenates it to the results of the previous cell. Then column B would use the result of the last column.

If you have Excel 2016, or Excel Live, Microsoft added a new function called TEXTJOIN. Using that, you can get the results you want like this:

AB
1IDName
210Al
320Brianne
434Cal
545Dyan
625Ed
729Felice
830Greg
955Hal

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



That's just the lookup sheet. Here's the formula:

ABCDEF
1IDVlookups?Col1Col2Col3Col4
21Cal; Dyan3445
32Brianne; Ed; Felice; Greg20253029
43Al10

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

Array Formulas
CellFormula
B2{=TEXTJOIN("; ",TRUE,IF(C2:G2=Sheet2!$A$2:$A$20,Sheet2!$B$2:$B$20&"",""))}

<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>



In some basic testing, it works OK, but occasionally the order of the names doesn't match the order of the IDs.

If you don't have TEXTJOIN, or if the order is an issue, and you don't want to use the extra 45-column method, we'd have to write a UDF to do this. If you want to try that, let me know and I'll write it up.

Hope this helps.
 
Upvote 0
Can you use something like this? The first formula is to created the concatenated items in a cell. The next formula is to list the all the numbers for a given ID. In the result table, E2:E4 shows 1,2 and 3. The first concatenation formula is in F2. The formula is =concatenate(transpose(if(a2:a8=e2,c2:c6))). Highlight the transpose(........) part of your formula with your mouse. Hit F9. Remove the {, all the FALSES ";" and last }. Hit enter. The second formula is G2. The formula is
=INDEX($B$2:$B$8,SMALL(IF($A$2:$A$8=$E$2,ROW($B$2:$B$8)-ROW($B$2)+1),COLUMNS($G$2:G2))) You need to us Cntrl+Shift+Enter. Copy across

IDNumberNameIDNameNumber
310Al1Cal ; Dyan 1045
220Brianne2Brianne ; Ed ; Felice ; Greg 20252930
134Cal3Al 10
145Dyan
225Ed
229Felice
230Greg

<colgroup><col span="5"><col><col span="4"></colgroup><tbody>
</tbody>


<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,214,885
Messages
6,122,085
Members
449,064
Latest member
MattDRT

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